1111import pathlib
1212import shutil
1313import sys
14- from typing import List
14+ import typing as t
1515
1616import click
1717
@@ -444,7 +444,7 @@ def load_workspace(
444444
445445def 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):
467467def 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
554554def 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