|
15 | 15 | import kaptan
|
16 | 16 | from click.exceptions import FileError
|
17 | 17 |
|
18 |
| -from libtmux.common import has_gte_version, has_minimum_version, which |
| 18 | +from libtmux.common import ( |
| 19 | + has_gte_version, |
| 20 | + has_minimum_version, |
| 21 | + which, |
| 22 | + get_version, |
| 23 | + tmux_cmd, |
| 24 | + which |
| 25 | +) |
19 | 26 | from libtmux.exc import LibTmuxException, TmuxCommandNotFound
|
20 | 27 | from libtmux.server import Server
|
| 28 | +from libtmux import __version__ as libtmux_version |
21 | 29 |
|
22 |
| -from . import config, exc, log, util |
| 30 | +from . import config, exc, log, util, __file__ as tmuxp_path |
23 | 31 | from .__about__ import __version__
|
24 | 32 | from ._compat import string_types
|
25 | 33 | from .workspacebuilder import WorkspaceBuilder, freeze
|
@@ -1198,3 +1206,56 @@ def command_ls():
|
1198 | 1206 | if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
|
1199 | 1207 | continue
|
1200 | 1208 | print(stem)
|
| 1209 | + |
| 1210 | + |
| 1211 | +@cli.command(name='debug-info', short_help='Print out all diagnostic info') |
| 1212 | +def command_debug_info(): |
| 1213 | + """ |
| 1214 | + """ |
| 1215 | + |
| 1216 | + def prepend_tab(strings): |
| 1217 | + """ |
| 1218 | + """ |
| 1219 | + return list(map( |
| 1220 | + lambda x: '\t%s' % x, |
| 1221 | + strings |
| 1222 | + )) |
| 1223 | + |
| 1224 | + def format_tmux_resp(std_resp): |
| 1225 | + """ |
| 1226 | + """ |
| 1227 | + return '\n'.join([ |
| 1228 | + *prepend_tab(std_resp.stdout), |
| 1229 | + click.style( |
| 1230 | + '\n'.join(prepend_tab(std_resp.stderr)), |
| 1231 | + fg='red' |
| 1232 | + ) |
| 1233 | + ]) |
| 1234 | + |
| 1235 | + output = [ |
| 1236 | + 'python version: %s' % ' '.join(sys.version.split('\n')), |
| 1237 | + 'system PATH: %s' % os.environ['PATH'], |
| 1238 | + 'tmux version: %s' % get_version(), |
| 1239 | + 'libtmux version: %s' % libtmux_version, |
| 1240 | + 'tmuxp version: %s' % __version__, |
| 1241 | + 'tmux path: %s' % which('tmux'), |
| 1242 | + 'tmuxp path: %s' % tmuxp_path, |
| 1243 | + 'shell: %s' % os.environ['SHELL'], |
| 1244 | + 'tmux sessions:\n%s' % format_tmux_resp( |
| 1245 | + tmux_cmd('list-sessions') |
| 1246 | + ), |
| 1247 | + 'tmux windows:\n%s' % format_tmux_resp( |
| 1248 | + tmux_cmd('list-windows') |
| 1249 | + ), |
| 1250 | + 'tmux panes:\n%s' % format_tmux_resp( |
| 1251 | + tmux_cmd('list-panes') |
| 1252 | + ), |
| 1253 | + 'tmux global options:\n%s' % format_tmux_resp( |
| 1254 | + tmux_cmd('show-options', '-g') |
| 1255 | + ), |
| 1256 | + 'tmux window options:\n%s' % format_tmux_resp( |
| 1257 | + tmux_cmd('show-window-options', '-g') |
| 1258 | + ) |
| 1259 | + ] |
| 1260 | + |
| 1261 | + click.echo('\n'.join(output)) |
0 commit comments