A Command-Line Interface framework
Project description
Knack
_ _ | | ___ __ __ _ ___| | __ | |/ / '_ \ / _` |/ __| |/ / | <| | | | (_| | (__| < |_|\_\_| |_|\__,_|\___|_|\_\
A Command-Line Interface framework
` pip install knack `
Usage
from knack import CLI, CLICommandsLoader, CLICommand
def abc_list(myarg):
import string
return list(string.ascii_lowercase)
class MyCommandsLoader(CLICommandsLoader):
def load_command_table(self, args):
with CommandSuperGroup(__name__, self, '__main__#{}') as sg:
with sg.group('abc') as g:
g.command('list', 'abc_list')
return OrderedDict(self.command_table)
def load_arguments(self, command):
with ArgumentsContext(self, 'abc list') as ac:
ac.argument('myarg', type=int, default=100)
super(MyCommandsLoader, self).load_arguments(command)
mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader)
exit_code = mycli.invoke(sys.argv[1:])
sys.exit(exit_code)
More samples and snippets available at examples.
Documentation
Documentation is available at docs.
Developer Setup
In a virtual environment, install the requirements.txt file.
pip install -r requirements.txt
pip install -e .
Contribute Code
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
If you would like to become an active contributor to this project please follow the instructions provided in Contribution License Agreement
License
Knack is licensed under MIT.
Release History
0.1.0 (2017-06-16)
Initial release
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
Built Distribution
File details
Details for the file knack-0.1.0.tar.gz
.
File metadata
- Download URL: knack-0.1.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e700c40ffd9d58b6f000c841baac7d05577c7284fabeddc0279a1ebf6a61a57f |
|
MD5 | 6824b3c8089a257763a847f73cd46618 |
|
BLAKE2b-256 | 8bc0ace3208f7f2fbce1aa64c71c5524b054888ffb55907eedcb91f400a30475 |
File details
Details for the file knack-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: knack-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 39.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0efa787b7b4c1076b690a10551bc2b7e86fd806d1f73f1ac9ec5c74aa3fa207b |
|
MD5 | 7f0d0be59f6fa3d0d5ae631ae45c3064 |
|
BLAKE2b-256 | 5843f59d959897b41e0333e602e8611befc28cc066913134de3dced1f3deb79c |