diff --git a/.github/issue_template.md b/.github/issue_template.md index 5368bd0a61b..ef99c9b8c0a 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -2,23 +2,10 @@ * For general technical questions, problems or feature requests related to the code **in this repository** file an issue. ### Step 2: Provide tmuxp details - * Python version - * system PATH - * tmux version - * tmuxp version - * tmux path - * tmuxp path, - * libtmux version - * shell - * output of `tmux list-sessions`, `tmux list-windows`, `tmux list-panes` - * output of `tmux show-options -g`, `tmux show-window-options -g` - * output of `tmuxp freeze ` + * Include output of `tmuxp debug-info` + * Include any other pertinant system info not captured -### Step 3: Describe your environment - * Architecture: _____ - * OS version: _____ - -### Step 4: Describe the problem: +### Step 3: Describe the problem: #### Steps to reproduce: 1. _____ 2. _____ diff --git a/CHANGES b/CHANGES index be938951cb5..5529eb9d671 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Here you can find the recent changes to tmuxp current ------- +- :issue:`352` New command ``tmuxp debug-info`` for creating github issues - *Insert changes/features/fixes for next release here* tmuxp 1.6.1 (2020-11-07) diff --git a/README.rst b/README.rst index dc9f150d305..5ed311bb748 100644 --- a/README.rst +++ b/README.rst @@ -177,6 +177,21 @@ You can auto confirm the prompt. In this case no preview will be shown. $ tmuxp convert --yes filename +Debug Info +--------- + +Collect system info to submit with a Github issue + +.. code-block:: sh + + $ tmuxp debug-info + -------------------------- + environment: + system: Linux + arch: x86_64 + ... + + Docs / Reading material ----------------------- diff --git a/docs/cli.rst b/docs/cli.rst index 59cb2cee60b..5d9b3fc4bee 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -184,6 +184,22 @@ are created, the last session is named from the terminal. $ tmxup load -s ... +.. _cli_debug_info: + +Debug Info +---------- + +Use to collect all relevant information for submitting an issue to the project. + +.. code-block:: bash + + $ tmuxp debug-info + -------------------------- + environment: + system: Linux + arch: x86_64 + ... + .. _cli_import: Import diff --git a/pyproject.toml b/pyproject.toml index 1338e43e524..56bd8985bda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ skip-string-normalization = true [tool.poetry] name = "tmuxp" -version = "1.6.1" +version = "1.6.2" description = "tmux session manager" license = "MIT" authors = ["Tony Narlock "] diff --git a/tests/test_cli.py b/tests/test_cli.py index 2741a30a2f7..c60d3b528c3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -16,6 +16,7 @@ from tmuxp import cli, config, exc from tmuxp.cli import ( command_ls, + command_debug_info, get_config_dir, is_pure_name, load_workspace, @@ -953,3 +954,24 @@ def test_ls_cli(monkeypatch, tmpdir): runner = CliRunner() cli_output = runner.invoke(command_ls).output assert cli_output == '\n'.join(stems) + '\n' + + +def test_debug_info_cli(monkeypatch, tmpdir): + monkeypatch.setenv('SHELL', '/bin/bash') + + runner = CliRunner() + cli_output = runner.invoke(command_debug_info).output + assert 'environment' in cli_output + assert 'python version' in cli_output + assert 'system PATH' in cli_output + assert 'tmux version' in cli_output + assert 'libtmux version' in cli_output + assert 'tmuxp version' in cli_output + assert 'tmux path' in cli_output + assert 'tmuxp path' in cli_output + assert 'shell' in cli_output + assert 'tmux session' in cli_output + assert 'tmux windows' in cli_output + assert 'tmux panes' in cli_output + assert 'tmux global options' in cli_output + assert 'tmux window options' in cli_output diff --git a/tmuxp/__about__.py b/tmuxp/__about__.py index 7fe395812e9..eaa33c135f6 100644 --- a/tmuxp/__about__.py +++ b/tmuxp/__about__.py @@ -1,6 +1,6 @@ __title__ = 'tmuxp' __package_name__ = 'tmuxp' -__version__ = '1.6.1' +__version__ = '1.6.2' __description__ = 'tmux session manager' __email__ = 'tony@git-pull.com' __author__ = 'Tony Narlock' diff --git a/tmuxp/cli.py b/tmuxp/cli.py index 6b1ac0cf5df..72e79ce624e 100644 --- a/tmuxp/cli.py +++ b/tmuxp/cli.py @@ -9,17 +9,26 @@ import logging import os +import platform import sys import click import kaptan from click.exceptions import FileError -from libtmux.common import has_gte_version, has_minimum_version, which +from libtmux.common import ( + has_gte_version, + has_minimum_version, + which, + get_version, + tmux_cmd, +) from libtmux.exc import TmuxCommandNotFound from libtmux.server import Server -from . import config, exc, log, util +from libtmux import __version__ as libtmux_version + +from . import config, exc, log, util, __file__ as tmuxp_path from .__about__ import __version__ from ._compat import PY3, PYMINOR, string_types from .workspacebuilder import WorkspaceBuilder, freeze @@ -1054,3 +1063,66 @@ def command_ls(): if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS: continue print(stem) + + +@cli.command(name='debug-info', short_help='Print out all diagnostic info') +def command_debug_info(): + """ + Print debug info to submit with Issues. + """ + + def prepend_tab(strings): + """ + Prepend tab to strings in list. + """ + return list(map(lambda x: '\t%s' % x, strings)) + + def output_break(): + """ + Generate output break. + """ + return '-' * 25 + + def format_tmux_resp(std_resp): + """ + Format tmux command response for tmuxp stdout. + """ + return '\n'.join( + [ + '\n'.join(prepend_tab(std_resp.stdout)), + click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'), + ] + ) + + output = [ + output_break(), + 'environment:\n%s' + % '\n'.join( + prepend_tab( + [ + 'dist: %s' % platform.platform(), + 'arch: %s' % platform.machine(), + 'uname: %s' % '; '.join(platform.uname()[:3]), + 'version: %s' % platform.version(), + ] + ) + ), + output_break(), + 'python version: %s' % ' '.join(sys.version.split('\n')), + 'system PATH: %s' % os.environ['PATH'], + 'tmux version: %s' % get_version(), + 'libtmux version: %s' % libtmux_version, + 'tmuxp version: %s' % __version__, + 'tmux path: %s' % which('tmux'), + 'tmuxp path: %s' % tmuxp_path, + 'shell: %s' % os.environ['SHELL'], + output_break(), + 'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')), + 'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')), + 'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')), + 'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')), + 'tmux window options:\n%s' + % format_tmux_resp(tmux_cmd('show-window-options', '-g')), + ] + + click.echo('\n'.join(output))