Skip to main content

CLI application commands parser

Project description

commandparse

Module to parse command based CLI application.

Usage:

  • Subclass the Command class
  • Add a method with a name such as prefix_commandname with kwargs as required argument
  • Create an ArgumentParser instance
  • Call the Subclass.add_suparsers with the ArgumentParser instance and other settings
  • Use the dispatch_command function with the args returned by parser.parse_args()
parser = ArgumentParser(...)
[...]
Subclass.add_subparsers(parser, prefixes=["get_", "do_", ...], title="commands", description="available commands")

cmd = Subclass(...)
cmd.dispatch_command(commands, args)

See example.py for a more complete example. For a real world application using this lib, see: https://github.com/franc-pentest/ldeep

Project details


Download files

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

Files for commandparse, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size commandparse-1.1.1.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page