Skip to main content

Make command-line interface scripts with ease

Project description

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

TODO

This is still in development. The following is planned:

  • Handling of keyword arguments
  • Increase supported types

Feel free to open issues for bugs and feature requests.

PRs are welcome too!

Enjoy :)

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

pattern-cli-0.0.2.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

pattern_cli-0.0.2-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page