Build CLI Tools with ease
Project description
pyclilib
Python Library to create CLI tools using Subject-Verb-Object pattern
my-cmd [my-namespace] my-action my-resource [pos_args] [--options]
Quickstart 1: CLI without Namespaces
pip install pyclilib
- Create a hello world CLI
import clilib
@clilib.decorator.resource
class MyResource():
@clilib.decorator.get
def get(self):
print "Hello world"
clilib.run("mycli")
- Run your program
$ python example.py get my-resource
Hello world
Quickstart 1: CLI with Namespaces
pip install clilib
- Create the runner,
example.py
import clilib
clilib.init("mycli")
clilib.run("mycli")
- Namespaces are sub-packages of an expected local
namespace
package
$ mkdir -p namespace namespace/my-namespace
$ touch namespace/__init__.py namespace/my-namespace/__init__.py
# namespace/my-namespace/__init__.py
import clilib
@clilib.decorator.resource
class MyResource():
@clilib.decorator.verb
def get(self):
print("Hello World")
- Run your program
$ python example.py my-namespace get my-resource
Hello World
Notes
- You can either have
cli namespace action resource
ORcli action resource
in the future
Roadmap
- Global Config -- Potential
- Namespace
- Conditional Args
- CLI without resource ex.
git init
Testing
- flake8
- pytest
- pylogrus
TODO
- How to make log level configurable?
Since decorators run during "compile"(?) time, setting the level through
clilib.run("foo", logging.DEBUG)
will set the level after the decorators do their thing. Same story withclilib._log_level = logging.DEBUG
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
pyclilib-0.2.0.tar.gz
(5.1 kB
view hashes)