Skip to content

Commit 8f24fd2

Browse files
committed
Adding debug-info command
1 parent 888b2b3 commit 8f24fd2

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 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 PY3, PYMINOR, string_types
2533
from .workspacebuilder import WorkspaceBuilder, freeze
@@ -1054,3 +1062,56 @@ def command_ls():
10541062
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
10551063
continue
10561064
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

Comments
 (0)