From b09d6a0a2d9887b5560a3b49cb8a603a33ec4828 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Sat, 6 Apr 2024 20:52:13 -0600 Subject: improved color picker --- src/get_args.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/get_args.py') diff --git a/src/get_args.py b/src/get_args.py index ebdf464..45f41cf 100644 --- a/src/get_args.py +++ b/src/get_args.py @@ -2,20 +2,30 @@ import user_interface import manage_saves import os from rich import print + + def get_args(args, walls_dir) -> tuple: # arguments that can be passed into program + VALID_ARGS = ['-r', '-p', '--initialize', '--reconfigure'] + initialize = False reconfigure = False color_save = None - VALID_ARGS = ['-r', '-p', '--initialize', '--reconfigure'] + + # load saved palette if '-p' in args: index = args.index('-p') - if os.path.isfile(args[index + 1]): - color_save = manage_saves.load_color_palette(args[index + 1]) - else: - print('invalid arguments. -p should be followed by a color palette save') - exit(2) + try: + if os.path.isfile(args[index + 1]): + color_save = manage_saves.load_color_palette(args[index + 1]) + else: + print(f'[bold red] Error!! invalid argument {args[index + 1]}. -p should be followed by a color palette save') + exit(2) + except IndexError: + print('[bold red]Error!! -p should be followed by location of a color palette save') + usage(args) + exit(2) if '-r' in args: img_path = user_interface.pickRandomWallpaper(walls_dir) @@ -32,6 +42,7 @@ def get_args(args, walls_dir) -> tuple: reconfigure = True return img_path, initialize, reconfigure, color_save + def usage(args) -> None: print(f"""Instant Rice - An automatic theming utilitiy -- cgit v1.2.3