Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/tmuxp/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions src/tmuxp/cli/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 0 additions & 9 deletions src/tmuxp/cli/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
36 changes: 36 additions & 0 deletions tests/cli/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")