A Command-Line Interface framework
Project description
Knack
_ _ | | ___ __ __ _ ___| | __ | |/ / '_ \ / _` |/ __| |/ / | <| | | | (_| | (__| < |_|\_\_| |_|\__,_|\___|_|\_\
A Command-Line Interface framework
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
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.0.1.tar.gz
.
File metadata
- Download URL: knack-0.0.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 263fdc9664e36e82a7a40fab30e7542d1c67be40e4e3b97c524cbb32bcee637e |
|
MD5 | 6def6a8a8a55bcd5fce33344bfc07010 |
|
BLAKE2b-256 | b4a8a710495957a7defd4893bb22786353a35945969906902c124e0f5318d10a |
File details
Details for the file knack-0.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: knack-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 38.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bd57b6a59ed3e56ac6747bb5ce5de2cf6689c62ceb29abac581c7d2172572f5 |
|
MD5 | 4d800af6bf1fd8f5711eca326373c116 |
|
BLAKE2b-256 | 45d7dfbc845554f4cd3b8790be6b06bec88c8b992d1fe8bbc2828009933be789 |