Skip to content

Instantly share code, notes, and snippets.

@msikma
Created November 26, 2015 13:58
Show Gist options
  • Save msikma/50e9a0271dceb8d4e72e to your computer and use it in GitHub Desktop.
Save msikma/50e9a0271dceb8d4e72e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import argparse
argparser = argparse.ArgumentParser(add_help=True)
argparser.description = 'Description.'
argparser.epilog = 'Epilog.'
argparser.add_argument('--version', action='version', version='1.0.0')
subparsers = argparser.add_subparsers(
title='Positional arguments',
dest='posarg'
)
test_arg_1 = subparsers.add_parser('c1', help='c1 help')
test_arg_1.add_argument('-f', '--foo', action='store', help='foo')
test_arg_2 = subparsers.add_parser('c2', aliases=['co'], help='c2 help')
test_arg_2.add_argument('-b', '--bar', action='store', type=int, help='bar')
args = argparser.parse_args()
print(repr(args))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment