Created
July 15, 2018 14:45
-
-
Save akahana-1/5bab2657dcc463f30a8accfe1e2096e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 argparse | |
def foo(): | |
pass | |
def bar(): | |
pass | |
def parse(): | |
parser = argparse.ArgumentParser() | |
subparsers = parser.add_subparsers() | |
pa = subparsers.add_parser("hoge") | |
pa.set_defaults(func=foo) | |
pb = subparsers.add_parser("fuga") | |
pb.set_defaults(func=bar) | |
return parser.parse_args() | |
if __name__ == "__main__": | |
args = parse() | |
args.func(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment