Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ranzvi/cli_parser

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

pypi: https://pypi.org/project/cli-parser/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.