Skip to main content

Extensible CLI parser.

Project description

nr.cliparser

– Extensible CLI parser.

Work in progress

Example

import nr.cliparser

parser = nr.cliparser.Parser()
parser.argument('-h', nargs=0, help='Show this help.')
parser.argument('script', nargs='?', help='A script to run.')
parser.argument('argv', nargs='...', help='Arguments for the script.')

install = parser.subparser('--install', help='Install a packge.')
install.argument('ref', nargs='?', multiple=True, help='A package reference.')
install.argument('-e', metavar='ref', help='A package reference to install editable.', multiple=True)
install.argument('-g', nargs=0, help='Install globally.')
install.argument('-r', nargs=0, help='Install into root.')

args = parser.parse()
if args['h']:
  parser.print_help()
  exit()

print(args)
$ python3 example.py -h
usage: example -h  [script] ... --install [ [ref] -e <ref> -g  -r ] 

-h                 Show this help.                                    
[script]           A script to run.                                   
...                Arguments for the script.                          
--install [ ... ]  Install a packge.                                  
  [ref]            A package reference.                               
  -e <ref>         A package reference to install editable.           
  -g               Install globally.                                  
  -r               Install into root.                                 

$ python3 example.py --install -e scope@package  
{'install': {'e': ['scope@package'], 'ref': [], 'g': False, 'r': False}, 'h': False, 'script': None, 'argv': []}

Changes

v0.1.0

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nr.cliparser-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file nr.cliparser-0.1.0.tar.gz.

File metadata

  • Download URL: nr.cliparser-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.4

File hashes

Hashes for nr.cliparser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62e1ae23b99885a32a1649663de9799bf31009f0aad8d905b92cc5b426677048
MD5 c4e4bb08c24d7397aed7650207c8dfb5
BLAKE2b-256 8fdf1d061d0e67a4c56544fc0977724f3bbe70ef90fad5bc52ad2ca5c53ab67c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page