mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-05-21 00:30:53 +02:00
args: cleanup
This commit is contained in:
parent
0b3e8fafbf
commit
8f331d1ef1
@ -26,7 +26,7 @@ from . import util
|
|||||||
from . import wallpaper
|
from . import wallpaper
|
||||||
|
|
||||||
|
|
||||||
def get_args(args):
|
def get_args():
|
||||||
"""Get the script arguments."""
|
"""Get the script arguments."""
|
||||||
description = "wal - Generate colorschemes on the fly"
|
description = "wal - Generate colorschemes on the fly"
|
||||||
arg = argparse.ArgumentParser(description=description)
|
arg = argparse.ArgumentParser(description=description)
|
||||||
@ -88,31 +88,27 @@ def get_args(args):
|
|||||||
arg.add_argument("-e", action="store_true",
|
arg.add_argument("-e", action="store_true",
|
||||||
help="Skip reloading gtk/xrdb/i3/sway/polybar")
|
help="Skip reloading gtk/xrdb/i3/sway/polybar")
|
||||||
|
|
||||||
return arg.parse_args(args)
|
return arg
|
||||||
|
|
||||||
|
|
||||||
def process_args_exit(args):
|
def parse_args_exit(parser):
|
||||||
"""Process args that exit."""
|
"""Process args that exit."""
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not len(sys.argv) > 1:
|
if not len(sys.argv) > 1:
|
||||||
print("error: wal needs to be given arguments to run.\n"
|
parser.error("wal needs to be given arguments to run.")
|
||||||
" Refer to \"wal -h\" for more info.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args.i and args.theme:
|
|
||||||
print("error: Conflicting arguments -i and -f.\n"
|
|
||||||
" Refer to \"wal -h\" for more info.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if not args.i and not args.theme and not args.R:
|
|
||||||
print("error: No input specified.\n"
|
|
||||||
" --theme, -i or -R are required.\n"
|
|
||||||
" Refer to \"wal -h\" for more info.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if args.v:
|
if args.v:
|
||||||
print("wal", __version__)
|
print("wal", __version__)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
if args.i and args.theme:
|
||||||
|
parser.error("Conflicting arguments -i and -f.")
|
||||||
|
|
||||||
|
if not args.i and not args.theme and not args.R:
|
||||||
|
parser.error("No input specified.\n"
|
||||||
|
"--theme, -i or -R are required.")
|
||||||
|
|
||||||
if args.r:
|
if args.r:
|
||||||
reload.colors()
|
reload.colors()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -129,8 +125,10 @@ def process_args_exit(args):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def process_args(args):
|
def parse_args(parser):
|
||||||
"""Process args."""
|
"""Process args."""
|
||||||
|
args = parser.parse_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")
|
||||||
@ -181,9 +179,10 @@ def process_args(args):
|
|||||||
def main():
|
def main():
|
||||||
"""Main script function."""
|
"""Main script function."""
|
||||||
util.setup_logging()
|
util.setup_logging()
|
||||||
args = get_args(sys.argv[1:])
|
parser = get_args()
|
||||||
process_args_exit(args)
|
|
||||||
process_args(args)
|
parse_args_exit(parser)
|
||||||
|
parse_args(parser)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user