From 61116b31da9f366456de21f55b5289dcb670e96d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Jun 2017 19:33:36 +1000 Subject: Args: Move most arg parsing to a function --- wal.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'wal.py') diff --git a/wal.py b/wal.py index 0728d2a..271c9aa 100755 --- a/wal.py +++ b/wal.py @@ -60,6 +60,28 @@ def get_args(): return arg.parse_args() +def process_args(args): + """Process args""" + # If no args were passed. + if not len(sys.argv) > 1: + print("error: wal needs to be given arguments to run.") + print(" Refer to 'wal -h' for more info.") + exit(1) + + # -q + if args.q: + sys.stdout = open('/dev/null', 'w') + sys.stderr = open('/dev/null', 'w') + + # -c + if args.c: + shutil.rmtree(SCHEME_DIR) + + # -r + if args.r: + reload_colors(args.t) + + # }}} @@ -372,25 +394,7 @@ def main(): """Main script function.""" # Get the args. args = get_args() - - # If no args were passed. - if not len(sys.argv) > 1: - print("error: wal needs to be given arguments to run.") - print(" Refer to 'wal -h' for more info.") - exit(1) - - # -q - if args.q: - sys.stdout = open('/dev/null', 'w') - sys.stderr = open('/dev/null', 'w') - - # -c - if args.c: - shutil.rmtree(SCHEME_DIR) - - # -r - if args.r: - reload_colors(args.t) + process_args(args) # Create colorscheme dir. pathlib.Path(SCHEME_DIR).mkdir(parents=True, exist_ok=True) -- cgit v1.2.3