Skip to content

Commit 63f797d

Browse files
committed
Adding debug-info command
1 parent be35db2 commit 63f797d

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

tmuxp/cli.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
import kaptan
1616
from click.exceptions import FileError
1717

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+
)
1926
from libtmux.exc import LibTmuxException, TmuxCommandNotFound
2027
from libtmux.server import Server
28+
from libtmux import __version__ as libtmux_version
2129

22-
from . import config, exc, log, util
30+
from . import config, exc, log, util, __file__ as tmuxp_path
2331
from .__about__ import __version__
2432
from ._compat import string_types
2533
from .workspacebuilder import WorkspaceBuilder, freeze
@@ -1198,3 +1206,56 @@ def command_ls():
11981206
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
11991207
continue
12001208
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

Comments
 (0)