|
10 | 10 | import importlib |
11 | 11 | import logging |
12 | 12 | import os |
| 13 | +import platform |
13 | 14 | import sys |
14 | 15 |
|
15 | 16 | import click |
16 | 17 | import kaptan |
17 | 18 | from click.exceptions import FileError |
18 | 19 |
|
19 | | -from libtmux.common import has_gte_version, has_minimum_version, which |
| 20 | +from libtmux.common import ( |
| 21 | + has_gte_version, |
| 22 | + has_minimum_version, |
| 23 | + which, |
| 24 | + get_version, |
| 25 | + tmux_cmd, |
| 26 | +) |
20 | 27 | from libtmux.exc import TmuxCommandNotFound |
21 | 28 | from libtmux.server import Server |
22 | 29 |
|
23 | | -from . import config, exc, log, util |
| 30 | +from libtmux import __version__ as libtmux_version |
| 31 | + |
| 32 | +from . import config, exc, log, util, __file__ as tmuxp_path |
24 | 33 | from .__about__ import __version__ |
25 | 34 | from ._compat import PY3, PYMINOR, string_types |
26 | 35 | from .workspacebuilder import WorkspaceBuilder, freeze |
@@ -1100,3 +1109,66 @@ def command_ls(): |
1100 | 1109 | if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS: |
1101 | 1110 | continue |
1102 | 1111 | print(stem) |
| 1112 | + |
| 1113 | + |
| 1114 | +@cli.command(name='debug-info', short_help='Print out all diagnostic info') |
| 1115 | +def command_debug_info(): |
| 1116 | + """ |
| 1117 | + Print debug info to submit with Issues. |
| 1118 | + """ |
| 1119 | + |
| 1120 | + def prepend_tab(strings): |
| 1121 | + """ |
| 1122 | + Prepend tab to strings in list. |
| 1123 | + """ |
| 1124 | + return list(map(lambda x: '\t%s' % x, strings)) |
| 1125 | + |
| 1126 | + def output_break(): |
| 1127 | + """ |
| 1128 | + Generate output break. |
| 1129 | + """ |
| 1130 | + return '-' * 25 |
| 1131 | + |
| 1132 | + def format_tmux_resp(std_resp): |
| 1133 | + """ |
| 1134 | + Format tmux command response for tmuxp stdout. |
| 1135 | + """ |
| 1136 | + return '\n'.join( |
| 1137 | + [ |
| 1138 | + '\n'.join(prepend_tab(std_resp.stdout)), |
| 1139 | + click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'), |
| 1140 | + ] |
| 1141 | + ) |
| 1142 | + |
| 1143 | + output = [ |
| 1144 | + output_break(), |
| 1145 | + 'environment:\n%s' |
| 1146 | + % '\n'.join( |
| 1147 | + prepend_tab( |
| 1148 | + [ |
| 1149 | + 'dist: %s' % platform.platform(), |
| 1150 | + 'arch: %s' % platform.machine(), |
| 1151 | + 'uname: %s' % '; '.join(platform.uname()[:3]), |
| 1152 | + 'version: %s' % platform.version(), |
| 1153 | + ] |
| 1154 | + ) |
| 1155 | + ), |
| 1156 | + output_break(), |
| 1157 | + 'python version: %s' % ' '.join(sys.version.split('\n')), |
| 1158 | + 'system PATH: %s' % os.environ['PATH'], |
| 1159 | + 'tmux version: %s' % get_version(), |
| 1160 | + 'libtmux version: %s' % libtmux_version, |
| 1161 | + 'tmuxp version: %s' % __version__, |
| 1162 | + 'tmux path: %s' % which('tmux'), |
| 1163 | + 'tmuxp path: %s' % tmuxp_path, |
| 1164 | + 'shell: %s' % os.environ['SHELL'], |
| 1165 | + output_break(), |
| 1166 | + 'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')), |
| 1167 | + 'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')), |
| 1168 | + 'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')), |
| 1169 | + 'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')), |
| 1170 | + 'tmux window options:\n%s' |
| 1171 | + % format_tmux_resp(tmux_cmd('show-window-options', '-g')), |
| 1172 | + ] |
| 1173 | + |
| 1174 | + click.echo('\n'.join(output)) |
0 commit comments