Skip to content

Commit 08e11a2

Browse files
committed
Remove --list from tmuxp load.
1 parent eec8857 commit 08e11a2

File tree

1 file changed

+20
-46
lines changed

1 file changed

+20
-46
lines changed

tmuxp/cli.py

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -393,49 +393,29 @@ def command_freeze(args):
393393

394394
def command_load(args):
395395
"""Load a session from a tmuxp session file."""
396-
if args.list:
397-
startup(config_dir)
398-
configs_in_user = config.in_dir(config_dir)
399-
configs_in_cwd = config.in_cwd()
400-
401-
sys.exit()
402396

403-
output = ''
397+
if isinstance(args.config, list):
398+
args.config = ' '.join(args.config)
404399

405-
if not configs_in_user:
406-
output += '# %s: \n\tNone found.\n' % config_dir
400+
if '.' == args.config:
401+
if config.in_cwd():
402+
configfile = config.in_cwd()[0]
403+
print(configfile)
407404
else:
408-
output += '# %s: \n\t%s\n' % (
409-
config_dir, ', '.join(configs_in_user)
410-
)
411-
412-
if configs_in_cwd:
413-
output += '# current directory:\n\t%s' % (
414-
', '.join(configs_in_cwd)
415-
)
405+
sys.exit('No tmuxp configs found in current directory.')
406+
else:
407+
configfile = args.config
416408

417-
print(output)
418-
return
409+
file_user = os.path.join(config_dir, configfile)
410+
file_cwd = os.path.join(cwd_dir, configfile)
419411

420-
elif args.config:
421-
if '.' == args.config:
422-
if config.in_cwd():
423-
configfile = config.in_cwd()[0]
424-
print(configfile)
425-
else:
426-
sys.exit('No tmuxp configs found in current directory.')
427-
else:
428-
configfile = args.config
429-
file_user = os.path.join(config_dir, configfile)
430-
file_cwd = os.path.join(cwd_dir, configfile)
431-
432-
if os.path.exists(file_cwd) and os.path.isfile(file_cwd):
433-
print('load %s' % file_cwd)
434-
load_workspace(file_cwd, args)
435-
elif os.path.exists(file_user) and os.path.isfile(file_user):
436-
load_workspace(file_user, args)
437-
else:
438-
logger.error('%s not found.' % configfile)
412+
if os.path.exists(file_cwd) and os.path.isfile(file_cwd):
413+
print('load %s' % file_cwd)
414+
load_workspace(file_cwd, args)
415+
elif os.path.exists(file_user) and os.path.isfile(file_user):
416+
load_workspace(file_user, args)
417+
else:
418+
logger.error('%s not found.' % configfile)
439419

440420

441421
def command_import_teamocil(args):
@@ -847,16 +827,10 @@ def get_parser():
847827
'already exists, offer to attach instead.'
848828
)
849829

850-
loadgroup = load.add_mutually_exclusive_group(required=True)
851-
loadgroup.add_argument(
852-
'--list', dest='list', action='store_true',
853-
help='List config files available',
854-
)
855-
856-
loadgroup.add_argument(
830+
load.add_argument(
857831
dest='config',
858832
type=str,
859-
nargs='?',
833+
nargs='+',
860834
help='List config available in working directory and config folder.'
861835
).completer = ConfigFileCompleter(
862836
allowednames=('.yaml', '.json'), directories=False

0 commit comments

Comments
 (0)