Simple CLI Parser with command chaining
Project description
CLI Parser
Simple Chained Command Parser
This tool will allow you to create a simple command hierarchy to execute from the command line.
Example
from cli_parser import command, CliParser, ParentCommand, CommandException
get = ParentCommand('get')
@command
def product(x, y):
return x * y
@command
def sum(x, y):
return x + y
get.add_sub_cmds(product, sum)
parser = CliParser([get])
while True:
in_ = input("Enter command:\n==> ")
try:
response = parser.process_response(in_)
print(response)
except CommandException:
pass
Execute your script from the command line:
Enter command:
==> get product 5 10
50
Enter command:
==> get sum 10 20
30
Enter command:
==> q
'Quitting Interpreter'
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
cli_parser-0.1.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for cli_parser-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c843c7295793f0ff205f755f17e9082601dcd016d339a02234fea1b4ab878bb |
|
MD5 | 7df47a985abcb11b4b3644dcdafa7e0e |
|
BLAKE2b-256 | 4fb8d5bb47ded18f5416776d513523d24147b76d943ae4234798247764672063 |