-
-
Save zed/b94e3e9945debe25826d 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 | |
""" | |
Usage: | |
prog.py -h | -v | |
prog.py [-f FILE -F FORMAT | -u URL [-V] -F FORMAT] | |
Options: | |
-h --help help | |
-v --version version | |
-f FILE file | |
-F FORMAT format | |
-u URL url | |
-V --verbose verbose | |
""" | |
from docopt import docopt | |
if __name__ == '__main__': | |
arguments = docopt(__doc__, version='Prog 0.1') | |
print(arguments) |
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 python3 | |
from itertools import combinations | |
from subprocess import call, DEVNULL, STDOUT | |
def powerset(seq): | |
return (c for r in range(len(seq) + 1) for c in combinations(seq, r)) | |
for args in map(list, powerset("-f a -F b -u c -V d --unknown".split())): | |
rc = call(['./prog.py'] + args, stdin=DEVNULL, stdout=DEVNULL, stderr=STDOUT) | |
print("{} {}".format("pass" if rc == 0 else "fail", args)) | |
"""$ grep pass | |
pass [] | |
pass ['-f', 'a', '-F', 'b'] | |
pass ['-f', 'a', '-F', '-u'] | |
pass ['-f', 'a', '-F', 'c'] | |
pass ['-f', 'a', '-F', '-V'] | |
pass ['-f', 'a', '-F', 'd'] | |
pass ['-f', 'a', '-F', '--unknown'] | |
pass ['-F', 'b', '-u', 'c'] | |
pass ['-F', 'b', '-u', '-V'] | |
pass ['-F', 'b', '-u', 'd'] | |
pass ['-F', 'b', '-u', '--unknown'] | |
pass ['-F', 'b', '-u', 'c', '-V'] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment