I have some argparse code included below. In it I try to eat a --browsers with nargs=* and a --remote-url string arg. Both are optional. Anything else should be passed on to another application using argparse.REMAINDER. However, if I execute 'app --param-meant-for-lettuce blah' then my argparser complains instead of passing it on to the other app. Most other use cases appear to work fine (ie 'app somebarparamforotherapp' executes fine). Am I doing something wrong or is this an argparse defect? According to the documentation this should work. I'm executing this under Python 2.6 and 2.7.
--thanks
medwards
# Full file is available at
https://github.com/medwards/salad/blob/4512a69f508660c11472f879b94649bf0934f317/salad/cli.pydef main(args=sys.argv[1:]):
parser = argparse.ArgumentParser(prog="Salad", description='BDD browswer-automation made tasty.')
parser.add_argument('--browsers', default=DEFAULT_BROWSERS, nargs='*'
metavar='BROWSER', choices=BROWSER_CHOICES,
help=('List of browsers to use. Default is %s.' %
DEFAULT_BROWSERS))
parser.add_argument('--remote-url',
help='Selenium server url to use for browsers')
parser.add_argument('args', nargs=argparse.REMAINDER)
parsed_args = parser.parse_args()
world.drivers = parsed_args.browsers
world.remote_url = parsed_args.remote_url
lettuce_main(args=parsed_args.args)