Update argparse snippets.

This commit is contained in:
Ethan Dalool 2019-12-05 00:18:27 -08:00
parent 8a0fcb09ca
commit e3b2cd6d1d
2 changed files with 4 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import argparse
import sys
def $1_argparse(args):
print(args)
return $1()
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
@ -16,7 +16,7 @@ def main(argv):
parser.set_defaults(func=$1_argparse)
args = parser.parse_args(argv)
args.func(args)
return args.func(args)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))

View file

@ -4,7 +4,7 @@ import argparse
import sys
def $1_argparse(args):
print(args)
return $1()
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
@ -18,7 +18,7 @@ def main(argv):
p_example.set_defaults(func=$1_argparse)
args = parser.parse_args(argv)
args.func(args)
return args.func(args)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))