|
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 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 PY3, PYMINOR, string_types
|
25 | 33 | from .workspacebuilder import WorkspaceBuilder, freeze
|
@@ -1054,3 +1062,56 @@ def command_ls():
|
1054 | 1062 | if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
|
1055 | 1063 | continue
|
1056 | 1064 | print(stem)
|
| 1065 | + |
| 1066 | + |
| 1067 | +@cli.command(name='debug-info', short_help='Print out all diagnostic info') |
| 1068 | +def command_debug_info(): |
| 1069 | + """ |
| 1070 | + """ |
| 1071 | + |
| 1072 | + def prepend_tab(strings): |
| 1073 | + """ |
| 1074 | + """ |
| 1075 | + return list(map( |
| 1076 | + lambda x: '\t%s' % x, |
| 1077 | + strings |
| 1078 | + )) |
| 1079 | + |
| 1080 | + def format_tmux_resp(std_resp): |
| 1081 | + """ |
| 1082 | + """ |
| 1083 | + return '\n'.join([ |
| 1084 | + *prepend_tab(std_resp.stdout), |
| 1085 | + click.style( |
| 1086 | + '\n'.join(prepend_tab(std_resp.stderr)), |
| 1087 | + fg='red' |
| 1088 | + ) |
| 1089 | + ]) |
| 1090 | + |
| 1091 | + output = [ |
| 1092 | + 'python version: %s' % ' '.join(sys.version.split('\n')), |
| 1093 | + 'system PATH: %s' % os.environ['PATH'], |
| 1094 | + 'tmux version: %s' % get_version(), |
| 1095 | + 'libtmux version: %s' % libtmux_version, |
| 1096 | + 'tmuxp version: %s' % __version__, |
| 1097 | + 'tmux path: %s' % which('tmux'), |
| 1098 | + 'tmuxp path: %s' % tmuxp_path, |
| 1099 | + 'shell: %s' % os.environ['SHELL'], |
| 1100 | + 'tmux sessions:\n%s' % format_tmux_resp( |
| 1101 | + tmux_cmd('list-sessions') |
| 1102 | + ), |
| 1103 | + 'tmux windows:\n%s' % format_tmux_resp( |
| 1104 | + tmux_cmd('list-windows') |
| 1105 | + ), |
| 1106 | + 'tmux panes:\n%s' % format_tmux_resp( |
| 1107 | + tmux_cmd('list-panes') |
| 1108 | + ), |
| 1109 | + 'tmux global options:\n%s' % format_tmux_resp( |
| 1110 | + tmux_cmd('show-options', '-g') |
| 1111 | + ), |
| 1112 | + 'tmux window options:\n%s' % format_tmux_resp( |
| 1113 | + tmux_cmd('show-window-options', '-g') |
| 1114 | + ) |
| 1115 | + ] |
| 1116 | + |
| 1117 | + click.echo('\n'.join(output)) |
0 commit comments