30 lines
920 B
XML
30 lines
920 B
XML
<snippet>
|
|
<content><![CDATA[
|
|
import argparse
|
|
import sys
|
|
|
|
def $1_argparse(args):
|
|
return $1()
|
|
|
|
def main(argv):
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
|
|
parser.add_argument('required_positional')
|
|
parser.add_argument('optional_positional', nargs='?', default=None)
|
|
parser.add_argument('-k', '--kwarg', dest='kwarg', default=None)
|
|
parser.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
|
|
parser.set_defaults(func=$1_argparse)
|
|
|
|
args = parser.parse_args(argv)
|
|
return args.func(args)
|
|
|
|
if __name__ == '__main__':
|
|
raise SystemExit(main(sys.argv[1:]))
|
|
|
|
]]></content>
|
|
<tabTrigger>argparse</tabTrigger>
|
|
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
|
|
<!-- <tabTrigger>hello</tabTrigger> -->
|
|
<!-- Optional: Set a scope to limit where the snippet will trigger -->
|
|
<!-- <scope>source.python</scope> -->
|
|
</snippet>
|