Skip to content

HashLDash/cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cli

Cli is a Python library to help create command-line interfaces with ease.

Installation

pip install git+https://github.com/HashLDash/cli

Usage

from cli import cli

@cli("hello")
def hello():
  ''' This is a test command '''
  print("Hello, World!")

@cli("add <int:a> <int:b>")
def add(a, b):
  print(f'Adding {a} + {b} = {a+b}')

This would add two commands (and automagically a help command) that can be called like:

$ python command.py hello
Hello, World!
$ python command.py add 5 4
Adding 5 + 4 = 9
$ python command.py help
command.py help

    hello - This is a test command

You can also add shebangs, ommit the extension and link to your path to create a command for using like:

$ command hello
Hello, World!
$ command add 5 4
Adding 5 + 4 = 9

You can also pass keyword arguments, and those will be delivered to your function aswell.

TODO

This is still in development. The following is planned:

  • Increase supported types

Feel free to open issues for bugs and feature requests.

PRs are welcome too!

Enjoy :)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages