Skip to content

Commit 92ba6f4

Browse files
committed
fix(cli[load]): Add --detached to --here/--append mutual exclusion group
--detached silently overrode --here (short-circuited in _dispatch_build before reaching the here check). Now all three load modes (-d, -a/ --append, --here) are in the same argparse mutually exclusive group.
1 parent 151c693 commit 92ba6f4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/tmuxp/cli/load.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,13 @@ def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
898898
action="store_true",
899899
help="always answer yes",
900900
)
901-
parser.add_argument(
901+
load_mode_group = parser.add_mutually_exclusive_group()
902+
load_mode_group.add_argument(
902903
"-d",
903904
dest="detached",
904905
action="store_true",
905906
help="load the session without attaching it",
906907
)
907-
load_mode_group = parser.add_mutually_exclusive_group()
908908
load_mode_group.add_argument(
909909
"-a",
910910
"--append",

tests/cli/test_load.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,3 +1485,21 @@ def test_load_here_and_append_mutually_exclusive() -> None:
14851485
parser = create_parser()
14861486
with pytest.raises(SystemExit):
14871487
parser.parse_args(["load", "--here", "--append", "myconfig"])
1488+
1489+
1490+
def test_load_here_and_detached_mutually_exclusive() -> None:
1491+
"""--here and -d cannot be used together."""
1492+
from tmuxp.cli import create_parser
1493+
1494+
parser = create_parser()
1495+
with pytest.raises(SystemExit):
1496+
parser.parse_args(["load", "--here", "-d", "myconfig"])
1497+
1498+
1499+
def test_load_append_and_detached_mutually_exclusive() -> None:
1500+
"""--append and -d cannot be used together."""
1501+
from tmuxp.cli import create_parser
1502+
1503+
parser = create_parser()
1504+
with pytest.raises(SystemExit):
1505+
parser.parse_args(["load", "--append", "-d", "myconfig"])

0 commit comments

Comments
 (0)