summaryrefslogtreecommitdiff
path: root/src/get_args.py
diff options
context:
space:
mode:
authorChandler J <cjustice2000@gmail.com>2024-04-13 13:44:44 -0600
committerChandler J <cjustice2000@gmail.com>2024-04-13 13:44:44 -0600
commitfba95abb417e0907c6148b61acae791ae01adb28 (patch)
tree9c2bd4356857069d7c40a947bedc346bbf101ecd /src/get_args.py
parentd1f74e783cd9af20a81e86783e0b7fe23371e208 (diff)
more smarter and better
Diffstat (limited to 'src/get_args.py')
-rw-r--r--src/get_args.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/get_args.py b/src/get_args.py
index 9197995..5419fc4 100644
--- a/src/get_args.py
+++ b/src/get_args.py
@@ -17,19 +17,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple:
index = args.index('-p')
isFile = os.path.isfile(args[index + 1])
if isFile == True:
- print("reached")
theme = manage_saves.load_theme(args[index + 1])
+ img_path = grab_image(args)
elif '-t' in args:
theme = user_interface.themeSelector(theme_dir)
img_path = theme['wallpaper']
elif '-r' in args:
img_path = user_interface.pickRandomWallpaper(walls_dir)
else:
- img_path = f"{os.getcwd()}/{args[1]}"
- if not os.path.exists(img_path) and\
- args[1] not in VALID_ARGS:
- print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}')
- exit(2)
+ img_path = grab_image(args)
if '--initialize' in args:
initialize = True
@@ -38,6 +34,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple:
return img_path, initialize, reconfigure, theme
+def grab_image(args):
+ img_path = f"{os.getcwd()}/{args[1]}"
+ if not os.path.exists(img_path):
+ print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}')
+ exit(2)
+ else:
+ return img_path
+
+
def usage(args) -> None:
print(f"""Instant Rice - An automatic theming utilitiy