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 byparser.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
commandparse-1.1.2.tar.gz
(5.4 kB
view details)
File details
Details for the file commandparse-1.1.2.tar.gz
.
File metadata
- Download URL: commandparse-1.1.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bd7bdd01b52eaa32316d6149a00b4c3820a40ff2ad62476b46aaae65dbe9faa |
|
MD5 | ee2a58eb3c5bbfc1f677992e5234ea4f |
|
BLAKE2b-256 | 796b6f1879101e405e2a5c7d352b340bc97d1936f8d54a8934ae32aac1828e50 |