Created
December 7, 2016 23:07
-
-
Save ben-albrecht/f73bf354bdea4f021e8d3bad926140a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
from argparse import ArgumentParser | |
parser = ArgumentParser(prog='arg-parse testing') | |
parser.add_argument("-compopts","--compopts", action="append", dest="compopts") | |
strings = [ | |
'--compopts --fast', | |
'-compopts --fast', | |
'--compo --fast', | |
'--compo=--fast', # Only one that succeeds :( | |
'-compo=--fast', | |
'--compo "--fast"', | |
'-compo "--fast"', | |
] | |
for string in strings: | |
try: | |
parser.parse_args([string]) | |
except: | |
print(string, ': failed') | |
else: | |
print(string, ': succeeded') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment