mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-20 01:27:42 +02:00
args: cleanup
This commit is contained in:
parent
32dfd4f181
commit
041044ed05
@ -91,8 +91,8 @@ def get_args(args):
|
|||||||
return arg.parse_args(args)
|
return arg.parse_args(args)
|
||||||
|
|
||||||
|
|
||||||
def process_args(args):
|
def process_args_exit(args):
|
||||||
"""Process args."""
|
"""Process args that exit."""
|
||||||
if not len(sys.argv) > 1:
|
if not len(sys.argv) > 1:
|
||||||
print("error: wal needs to be given arguments to run.\n"
|
print("error: wal needs to be given arguments to run.\n"
|
||||||
" Refer to \"wal -h\" for more info.")
|
" Refer to \"wal -h\" for more info.")
|
||||||
@ -103,9 +103,9 @@ def process_args(args):
|
|||||||
" Refer to \"wal -h\" for more info.")
|
" Refer to \"wal -h\" for more info.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not args.i and not args.theme:
|
if not args.i and not args.theme and not args.R:
|
||||||
print("error: No input specified.\n"
|
print("error: No input specified.\n"
|
||||||
" --theme and -i are required.\n"
|
" --theme, -i or -R are required.\n"
|
||||||
" Refer to \"wal -h\" for more info.")
|
" Refer to \"wal -h\" for more info.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -128,6 +128,9 @@ def process_args(args):
|
|||||||
print("Backends:", colors.list_backends())
|
print("Backends:", colors.list_backends())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def process_args(args):
|
||||||
|
"""Process args."""
|
||||||
if args.q:
|
if args.q:
|
||||||
logging.getLogger().disabled = True
|
logging.getLogger().disabled = True
|
||||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||||
@ -144,14 +147,7 @@ def process_args(args):
|
|||||||
colors_plain = theme.file(args.theme)
|
colors_plain = theme.file(args.theme)
|
||||||
|
|
||||||
if args.R:
|
if args.R:
|
||||||
cache_file = os.path.join(CACHE_DIR, "colors.json")
|
colors_plain = theme.file(os.path.join(CACHE_DIR, "colors.json"))
|
||||||
|
|
||||||
if os.path.isfile(cache_file):
|
|
||||||
colors_plain = theme.file(cache_file)
|
|
||||||
|
|
||||||
else:
|
|
||||||
print("image: No colorscheme to restore, try 'wal -i' first.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args.a:
|
if args.a:
|
||||||
util.Color.alpha_num = args.a
|
util.Color.alpha_num = args.a
|
||||||
@ -161,7 +157,6 @@ def process_args(args):
|
|||||||
colors_plain["special"]["background"] = args.b
|
colors_plain["special"]["background"] = args.b
|
||||||
colors_plain["colors"]["color0"] = args.b
|
colors_plain["colors"]["color0"] = args.b
|
||||||
|
|
||||||
if args.i or args.theme or args.R:
|
|
||||||
if not args.n:
|
if not args.n:
|
||||||
wallpaper.change(colors_plain["wallpaper"])
|
wallpaper.change(colors_plain["wallpaper"])
|
||||||
|
|
||||||
@ -187,6 +182,7 @@ def main():
|
|||||||
"""Main script function."""
|
"""Main script function."""
|
||||||
util.setup_logging()
|
util.setup_logging()
|
||||||
args = get_args(sys.argv[1:])
|
args = get_args(sys.argv[1:])
|
||||||
|
process_args_exit(args)
|
||||||
process_args(args)
|
process_args(args)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user