diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-19 19:33:36 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-19 19:33:36 +1000 |
| commit | 61116b31da9f366456de21f55b5289dcb670e96d (patch) | |
| tree | 6b7eb2caa5b124cacc329ae524a28d2fc790b2d0 | |
| parent | 33638ecb92357e1e256e3c14099298a11883a8b1 (diff) | |
Args: Move most arg parsing to a function
| -rwxr-xr-x | wal.py | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -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) |
