Guest User

Untitled

a guest
Jan 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import argparse
  2.  
  3. if __name__ == '__main__':
  4. parser = argparse.ArgumentParser(
  5. formatter_class=argparse.ArgumentDefaultsHelpFormatter
  6. )
  7.  
  8. sub_parser = parser.add_subparsers(title='sub commands',
  9. help='sub commands help')
  10.  
  11. foo = sub_parser.add_parser('foo')
  12. foo.add_argument(
  13. '--a',
  14. action='store',
  15. default='1234',
  16. help='A'
  17. )
  18.  
  19. parser.parse_args(['foo', '--help'])
  20.  
  21. usage: test_args.py foo [-h] [--a A]
  22.  
  23. optional arguments:
  24. -h, --help show this help message and exit
  25. --a A A
  26.  
  27. Process finished with exit code 0
Add Comment
Please, Sign In to add comment