Last active
April 4, 2022 07:24
-
-
Save pointofpresence/7ee627a2f2c11116edd8a0706cba1322 to your computer and use it in GitHub Desktop.
Created with Copy to Gist
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
import getopt, sys | |
def main(): | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) | |
except getopt.GetoptError as err: | |
# print help information and exit: | |
print(err) # will print something like "option -a not recognized" | |
usage() | |
sys.exit(2) | |
output = None | |
verbose = False | |
for o, a in opts: | |
if o == "-v": | |
verbose = True | |
elif o in ("-h", "--help"): | |
usage() | |
sys.exit() | |
elif o in ("-o", "--output"): | |
output = a | |
else: | |
assert False, "unhandled option" | |
# ... | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment