|
9 | 9 |
|
10 | 10 | import logging |
11 | 11 | import os |
| 12 | +import platform |
12 | 13 | import sys |
13 | 14 |
|
14 | 15 | import click |
15 | 16 | import kaptan |
16 | 17 | from click.exceptions import FileError |
17 | 18 |
|
18 | | -from libtmux.common import has_gte_version, has_minimum_version, which |
| 19 | +from libtmux.common import ( |
| 20 | + has_gte_version, |
| 21 | + has_minimum_version, |
| 22 | + which, |
| 23 | + get_version, |
| 24 | + tmux_cmd, |
| 25 | +) |
19 | 26 | from libtmux.exc import TmuxCommandNotFound |
20 | 27 | from libtmux.server import Server |
21 | 28 |
|
22 | | -from . import config, exc, log, util |
| 29 | +from libtmux import __version__ as libtmux_version |
| 30 | + |
| 31 | +from . import config, exc, log, util, __file__ as tmuxp_path |
23 | 32 | from .__about__ import __version__ |
24 | 33 | from ._compat import PY3, PYMINOR, string_types |
25 | 34 | from .workspacebuilder import WorkspaceBuilder, freeze |
@@ -1054,3 +1063,66 @@ def command_ls(): |
1054 | 1063 | if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS: |
1055 | 1064 | continue |
1056 | 1065 | print(stem) |
| 1066 | + |
| 1067 | + |
| 1068 | +@cli.command(name='debug-info', short_help='Print out all diagnostic info') |
| 1069 | +def command_debug_info(): |
| 1070 | + """ |
| 1071 | + Print debug info to submit with Issues. |
| 1072 | + """ |
| 1073 | + |
| 1074 | + def prepend_tab(strings): |
| 1075 | + """ |
| 1076 | + Prepend tab to strings in list. |
| 1077 | + """ |
| 1078 | + return list(map(lambda x: '\t%s' % x, strings)) |
| 1079 | + |
| 1080 | + def output_break(): |
| 1081 | + """ |
| 1082 | + Generate output break. |
| 1083 | + """ |
| 1084 | + return '-' * 25 |
| 1085 | + |
| 1086 | + def format_tmux_resp(std_resp): |
| 1087 | + """ |
| 1088 | + Format tmux command response for tmuxp stdout. |
| 1089 | + """ |
| 1090 | + return '\n'.join( |
| 1091 | + [ |
| 1092 | + '\n'.join(prepend_tab(std_resp.stdout)), |
| 1093 | + click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'), |
| 1094 | + ] |
| 1095 | + ) |
| 1096 | + |
| 1097 | + output = [ |
| 1098 | + output_break(), |
| 1099 | + 'environment:\n%s' |
| 1100 | + % '\n'.join( |
| 1101 | + prepend_tab( |
| 1102 | + [ |
| 1103 | + 'dist: %s' % platform.platform(), |
| 1104 | + 'arch: %s' % platform.machine(), |
| 1105 | + 'uname: %s' % '; '.join(platform.uname()[:3]), |
| 1106 | + 'version: %s' % platform.version(), |
| 1107 | + ] |
| 1108 | + ) |
| 1109 | + ), |
| 1110 | + output_break(), |
| 1111 | + 'python version: %s' % ' '.join(sys.version.split('\n')), |
| 1112 | + 'system PATH: %s' % os.environ['PATH'], |
| 1113 | + 'tmux version: %s' % get_version(), |
| 1114 | + 'libtmux version: %s' % libtmux_version, |
| 1115 | + 'tmuxp version: %s' % __version__, |
| 1116 | + 'tmux path: %s' % which('tmux'), |
| 1117 | + 'tmuxp path: %s' % tmuxp_path, |
| 1118 | + 'shell: %s' % os.environ['SHELL'], |
| 1119 | + output_break(), |
| 1120 | + 'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')), |
| 1121 | + 'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')), |
| 1122 | + 'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')), |
| 1123 | + 'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')), |
| 1124 | + 'tmux window options:\n%s' |
| 1125 | + % format_tmux_resp(tmux_cmd('show-window-options', '-g')), |
| 1126 | + ] |
| 1127 | + |
| 1128 | + click.echo('\n'.join(output)) |
0 commit comments