%define scl rh-python36 %{?scl:%scl_package %{name}} %{!?scl:%global pkg_name %{name}} %define name knack %define version 0.3.3 %define unmangled_version 0.3.3 %define unmangled_version 0.3.3 %define release 1 Summary: A Command-Line Interface framework %{?scl:Requires: %{scl}-runtime} %{?scl:BuildRequires: %{scl}-runtime} Name: %{?scl_prefix}knack Version: %{version} Release: %{release} Source0: knack-%{unmangled_version}.tar.gz License: MIT Group: Development/Libraries BuildRoot: %{_tmppath}/knack-%{version}-%{release}-buildroot Prefix: %{_prefix} BuildArch: noarch Vendor: Microsoft Corporation Packager: Martin Juhl Url: https://github.com/microsoft/knack %description Knack ===== .. image:: https://img.shields.io/pypi/v/knack.svg :target: https://pypi.python.org/pypi/knack .. image:: https://img.shields.io/pypi/pyversions/knack.svg :target: https://pypi.python.org/pypi/knack .. image:: https://travis-ci.org/Microsoft/knack.svg?branch=master :target: https://travis-ci.org/Microsoft/knack ------------ :: _ _ | | ___ __ __ _ ___| | __ | |/ / '_ \ / _` |/ __| |/ / | <| | | | (_| | (__| < |_|\_\_| |_|\__,_|\___|_|\_\ **A Command-Line Interface framework** .. code-block:: bash pip install knack ------------ .. note:: The project is in `initial development phase `__ . We recommend pinning to at least a specific minor version when marking **knack** as a dependency in your project. ------------ Usage ===== .. code-block:: python import sys from collections import OrderedDict from knack import CLI, CLICommandsLoader, ArgumentsContext def abc_list(myarg): import string return list(string.ascii_lowercase) class MyCommandsLoader(CLICommandsLoader): def load_command_table(self, args): with CommandGroup(__name__, self, 'abc', '__main__#{}') 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. .. code-block:: bash pip install -r requirements.txt pip install -e . Run Automation ============== This project supports running automation using `tox `__. .. code-block:: bash pip install tox tox Real-world uses =============== - `Azure CLI `__: The Azure CLI 2.0 is Azure's new command line experience for managing Azure resources. - `VSTS CLI `__: A command-line interface for Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). With the VSTS CLI, you can manage and work with resources including pull requests, work items, builds, and more. - `Service Fabric CLI `__: A command-line interface for interacting with Azure Service Fabric clusters and their related entities. Do you use knack in your CLI as well? Open a pull request to include it here. We would love to have it in our list. Release History =============== See `GitHub Releases `__. 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 `__. %prep %{?scl:scl enable %{scl} - << \EOF} set -ex %setup -n knack-%{unmangled_version} -n knack-%{unmangled_version} %{?scl:EOF} %build %{?scl:scl enable %{scl} - << \EOF} set -ex python3 setup.py build %{?scl:EOF} %install %{?scl:scl enable %{scl} - << \EOF} set -ex python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES %{?scl:EOF} %clean %{?scl:scl enable %{scl} - << \EOF} set -ex rm -rf $RPM_BUILD_ROOT %{?scl:EOF} %files -f INSTALLED_FILES %defattr(-,root,root)