From 139815765414d09bc7e7de2c9abb8bd9398a5130 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 10 May 2016 08:16:33 -0400 Subject: [PATCH] Use argparse in runtests like Zeus intended --- runtests | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/runtests b/runtests index 162e23e..feacff3 100755 --- a/runtests +++ b/runtests @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +import argparse import os import sys import tempfile @@ -14,16 +15,19 @@ PACKAGE_NAME = os.environ.get( def main(sysargs=sys.argv[:]): - target = 'test' - if len(sysargs) > 1: - target = sysargs[1] - - { + targets = { 'vet': _vet, 'test': _test, 'gfmxr': _gfmxr - }[target]() + } + parser = argparse.ArgumentParser() + parser.add_argument( + 'target', nargs='?', choices=tuple(targets.keys()), default='test' + ) + args = parser.parse_args(sysargs[1:]) + + targets[args.target]() return 0