diff --git a/src/tmuxp/cli/__init__.py b/src/tmuxp/cli/__init__.py index 5fb5eda05e..86fe861225 100644 --- a/src/tmuxp/cli/__init__.py +++ b/src/tmuxp/cli/__init__.py @@ -282,16 +282,12 @@ class CLINamespace(argparse.Namespace): import_subparser_name : CLIImportSubparserName | None Source format chosen under ``tmuxp import``. Unset when ``import`` runs without one, so readers reach for it with :func:`getattr`. - version : bool - Declared for ``--version``/``-V``. argparse's version action prints and - exits on its own, so this is never assigned. """ log_level: CLIVerbosity color: CLIColorMode subparser_name: CLISubparserName import_subparser_name: CLIImportSubparserName | None - version: bool ns = CLINamespace() diff --git a/src/tmuxp/cli/freeze.py b/src/tmuxp/cli/freeze.py index b5721561ac..1fbbfdadf8 100644 --- a/src/tmuxp/cli/freeze.py +++ b/src/tmuxp/cli/freeze.py @@ -69,7 +69,7 @@ class CLIFreezeNamespace(argparse.Namespace): Format the workspace is written in (``-f``/``--workspace-format``). ``None`` infers it from the destination file's extension and prompts when that fails. - save_to : str | None + save_to : pathlib.Path | None Destination file (``-o``/``--save-to``). ``None`` prompts for a path, defaulting to the session name inside the tmuxp workspace directory. answer_yes : bool | None @@ -89,7 +89,7 @@ class CLIFreezeNamespace(argparse.Namespace): socket_name: str | None socket_path: str | None workspace_format: CLIOutputFormatLiteral | None - save_to: str | None + save_to: pathlib.Path | None answer_yes: bool | None quiet: bool | None force: bool | None @@ -142,13 +142,13 @@ def create_freeze_subparser( "-q", dest="quiet", action="store_true", - help="don't prompt for confirmation", + help="suppress informational output (use --yes to skip prompts)", ) parser.add_argument( "--force", dest="force", action="store_true", - help="overwrite the workspace file", + help="accept a prompted destination that already exists", ) return parser @@ -209,7 +209,7 @@ def command_freeze( ) sys.exit() - dest = args.save_to + dest: str | None = str(args.save_to) if args.save_to else None while not dest: save_to = os.path.abspath( os.path.join( diff --git a/src/tmuxp/cli/load.py b/src/tmuxp/cli/load.py index 0b761eb402..b2c94878af 100644 --- a/src/tmuxp/cli/load.py +++ b/src/tmuxp/cli/load.py @@ -89,7 +89,7 @@ def _silence_stream_handlers(logger_name: str = "tmuxp") -> t.Iterator[None]: from tmuxp.types import StrPath - CLIColorsLiteral: TypeAlias = t.Literal[56, 88] + CLIColorsLiteral: TypeAlias = t.Literal[256, 88] CLIColorModeLiteral: TypeAlias = t.Literal["auto", "always", "never"] class OptionOverrides(TypedDict): diff --git a/src/tmuxp/cli/shell.py b/src/tmuxp/cli/shell.py index aabc401589..4a7ca988e6 100644 --- a/src/tmuxp/cli/shell.py +++ b/src/tmuxp/cli/shell.py @@ -39,7 +39,6 @@ from typing import TypeAlias CLIColorModeLiteral: TypeAlias = t.Literal["auto", "always", "never"] - CLIColorsLiteral: TypeAlias = t.Literal[56, 88] CLIShellLiteral: TypeAlias = t.Literal[ "best", "pdb", @@ -69,12 +68,6 @@ class CLIShellNamespace(argparse.Namespace): socket_path : str | None Pass-through for ``tmux -S``. When neither this nor ``socket_name`` is given and ``TMUX`` is set, the socket path is read from that variable. - colors : CLIColorsLiteral | None - Color count forced on tmux. The ``shell`` subparser defines no - ``-2``/``-8`` flags, so argparse never sets this. - log_file : str | None - Destination for the file log. The ``shell`` subparser defines no - ``--log-file`` flag, so argparse never sets this. window_name : str | None Window bound to the shell's ``window`` variable. Unset when the positional is omitted, which falls back to the window owning the pane @@ -99,8 +92,6 @@ class CLIShellNamespace(argparse.Namespace): session_name: str socket_name: str | None socket_path: str | None - colors: CLIColorsLiteral | None - log_file: str | None window_name: str | None command: str | None shell: CLIShellLiteral | None diff --git a/tests/cli/test_freeze.py b/tests/cli/test_freeze.py index fd828dbb4a..6b147047ec 100644 --- a/tests/cli/test_freeze.py +++ b/tests/cli/test_freeze.py @@ -147,3 +147,39 @@ def test_freeze_overwrite( yaml_config_path = tmp_path / "exists.yaml" assert yaml_config_path.exists() + + +def _freeze_help(dest: str) -> str: + """Return the help text of the freeze flag storing into *dest*.""" + import argparse + + from tmuxp.cli.freeze import create_freeze_subparser + + parser = create_freeze_subparser(argparse.ArgumentParser(prog="freeze")) + action = next(a for a in parser._actions if a.dest == dest) + assert action.help is not None + return action.help + + +def test_freeze_save_to_parses_as_a_path() -> None: + """-o/--save-to stores a pathlib.Path, matching its declared type.""" + import argparse + import pathlib + + from tmuxp.cli.freeze import create_freeze_subparser + + parser = create_freeze_subparser(argparse.ArgumentParser(prog="freeze")) + args = parser.parse_args(["-o", "out.yaml"]) + assert isinstance(args.save_to, pathlib.Path) + + +def test_freeze_quiet_help_describes_what_it_silences() -> None: + """--quiet advertises output suppression, not prompt suppression.""" + help_text = _freeze_help("quiet") + assert "output" in help_text + assert "--yes" in help_text + + +def test_freeze_force_help_scopes_itself_to_the_prompt() -> None: + """--force advertises the prompted destination it actually affects.""" + assert "prompt" in _freeze_help("force")