summaryrefslogtreecommitdiff
path: root/src/get_args.py
diff options
context:
space:
mode:
authorChandler J <cjustice2000@gmail.com>2024-04-06 20:52:13 -0600
committerChandler J <cjustice2000@gmail.com>2024-04-06 20:52:44 -0600
commitb09d6a0a2d9887b5560a3b49cb8a603a33ec4828 (patch)
tree0fbfeab50c95e6732ab69b1e3dae852fd80b0598 /src/get_args.py
parentb7dc1316ab0eb51f408b2b7782571d868ad3b864 (diff)
improved color picker
Diffstat (limited to 'src/get_args.py')
-rw-r--r--src/get_args.py23
1 files changed, 17 insertions, 6 deletions
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