Skip to content

Commit f94dfc8

Browse files
committed
!squash more
1 parent 7ed4129 commit f94dfc8

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/tmuxp/cli/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,18 @@ def cli(args=None):
8888
if args.subparser_name is None:
8989
parser.print_help()
9090
return
91-
elif args.subparser_name == "sync":
92-
sync(
93-
repo_terms=args.repo_terms,
91+
elif args.subparser_name == "load":
92+
command_load(
9493
config=args.config,
95-
exit_on_error=args.exit_on_error,
94+
socket_name=args.socket_name,
95+
socket_path=args.socket_path,
96+
tmux_config_file=args.tmux_config_file,
97+
new_session_name=args.new_session_name,
98+
answer_yes=args.answer_yes,
99+
detached=args.detached,
100+
append=args.append,
101+
colors=args.colors,
102+
log_file=args.log_file,
96103
parser=parser,
97104
)
98105

src/tmuxp/cli/load.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pathlib
1212
import shutil
1313
import sys
14-
from typing import List
14+
import typing as t
1515

1616
import click
1717

@@ -444,7 +444,7 @@ def load_workspace(
444444

445445
def config_file_completion(ctx, params, incomplete):
446446
config_dir = pathlib.Path(get_config_dir())
447-
choices: List[pathlib.Path] = []
447+
choices: t.List[pathlib.Path] = []
448448

449449
# CWD Paths
450450
choices += sorted(
@@ -467,7 +467,6 @@ def config_file_completion(ctx, params, incomplete):
467467
def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
468468
parser.add_argument(
469469
"config",
470-
nargs=-1,
471470
help="Filepath to session or filename of session if in tmuxp config directory",
472471
)
473472
parser.add_argument(
@@ -512,6 +511,7 @@ def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
512511
)
513512
parser.add_argument(
514513
"-a",
514+
"--append",
515515
dest="append",
516516
action="store_true",
517517
help="load configuration, appending windows to the current session",
@@ -552,7 +552,6 @@ def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
552552

553553

554554
def command_load(
555-
ctx,
556555
config,
557556
socket_name,
558557
socket_path,
@@ -563,6 +562,7 @@ def command_load(
563562
append,
564563
colors,
565564
log_file,
565+
parser: t.Optional[argparse.ArgumentParser] = None,
566566
):
567567
"""Load a tmux workspace from each CONFIG.
568568
@@ -606,14 +606,14 @@ def command_load(
606606
"append": append,
607607
}
608608

609-
if not config:
610-
tmuxp_echo("Enter at least one CONFIG")
611-
tmuxp_echo(ctx.get_help(), color=ctx.color)
612-
ctx.exit()
609+
if config is None:
610+
tmuxp_echo("Enter at least one config")
611+
if parser is not None:
612+
parser.print_help()
613+
sys.exit()
613614

614615
if isinstance(config, str):
615616
load_workspace(config, **tmux_options)
616-
617617
elif isinstance(config, tuple):
618618
config = list(config)
619619
# Load each configuration but the last to the background
@@ -624,3 +624,5 @@ def command_load(
624624

625625
# todo: obey the -d in the cli args only if user specifies
626626
load_workspace(config[-1], **tmux_options)
627+
else:
628+
raise NotImplementedError(f"config {type(config)} with {config} not valid")

0 commit comments

Comments
 (0)