All Projects → contains-io → Rcli

contains-io / Rcli

Licence: mit
Rapidly create full-featured command line interfaces with help, subcommand dispatch, and validation.

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
bash
514 projects
python2
120 projects
types
53 projects

Projects that are alternatives of or similar to Rcli

Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+49033.33%)
Mutual labels:  command-line-tool, command-line, zsh
Kube Aliases
Kubernetes Aliases and Bash Functions
Stars: ✭ 40 (+344.44%)
Mutual labels:  command-line-tool, zsh, autocomplete
Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (+6844.44%)
Mutual labels:  command-line-tool, command-line, zsh
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+36333.33%)
Mutual labels:  command-line, zsh, autocomplete
Broot
A new way to see and navigate directory trees : https://dystroy.org/broot
Stars: ✭ 6,362 (+70588.89%)
Mutual labels:  command-line-tool, command-line
Zsh Z
Jump quickly to directories that you have visited "frecently." A native ZSH port of z.sh.
Stars: ✭ 562 (+6144.44%)
Mutual labels:  command-line-tool, zsh
Jsonui
jsonui is an interactive JSON explorer on your command line
Stars: ✭ 583 (+6377.78%)
Mutual labels:  command-line-tool, command-line
Spicetify Cli
Commandline tool to customize Spotify client. Supports Windows, MacOS and Linux.
Stars: ✭ 9,316 (+103411.11%)
Mutual labels:  command-line-tool, command-line
Dateutils
nifty command line date and time utilities; fast date calculations and conversion in the shell
Stars: ✭ 458 (+4988.89%)
Mutual labels:  command-line-tool, command-line
Autocomplete
Autocomplete for terminals on MacOS
Stars: ✭ 569 (+6222.22%)
Mutual labels:  zsh, autocomplete
Papis
Powerful and highly extensible command-line based document and bibliography manager.
Stars: ✭ 636 (+6966.67%)
Mutual labels:  command-line-tool, command-line
Cli
A command-line interface for Hetzner Cloud
Stars: ✭ 542 (+5922.22%)
Mutual labels:  command-line-tool, command-line
Cbt
CBT - fun, fast, intuitive, compositional, statically checked builds written in Scala
Stars: ✭ 489 (+5333.33%)
Mutual labels:  command-line-tool, command-line
Laminas Cli
Console command runner, exposing commands written in Laminas MVC and Mezzio components and applications
Stars: ✭ 25 (+177.78%)
Mutual labels:  command-line-tool, command-line
Node.cli Progress
⌛️ easy to use progress-bar for command-line/terminal applications
Stars: ✭ 466 (+5077.78%)
Mutual labels:  command-line-tool, command-line
Terjira
Terjira is a very interactive and easy to use CLI tool for Jira.
Stars: ✭ 713 (+7822.22%)
Mutual labels:  command-line-tool, command-line
Ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Stars: ✭ 28,564 (+317277.78%)
Mutual labels:  command-line-tool, command-line
Trek
Trek is a CLI/ncurses explorer for HashiCorp Nomad clusters.
Stars: ✭ 26 (+188.89%)
Mutual labels:  command-line-tool, command-line
Przm
🎨 A simple, yet feature rich color picker and manipulator
Stars: ✭ 17 (+88.89%)
Mutual labels:  command-line-tool, command-line
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (+4666.67%)
Mutual labels:  command-line-tool, command-line

rcli

|PyPI| |Python Versions| |Build Status| |Coverage Status| |Code Quality|

Rapidly create full-featured command line interfaces with help, subcommand dispatch, and validation.

rcli uses docopt_ to give you the control over your usage messages that you want, but adds functionality such as automatic subcommand dispatching, usage string wrapping, internationalization, and parameter validation.

Installation

Install it using pip:

::

pip install rcli

Features

  • Automatic creation of console scripts and entry points based on usage strings.
  • Argument parsing based on usage string.
  • Usage string wrapping.
  • Command line arguments are normalized into python function parameters.
  • Validation of command line arguments using PEP 484_ type hints.
  • Logging with multiple levels and crash log generation.
  • Color coded logging based on log level.
  • Extensible subcommand generation based on entry point groups.

Upcoming Features

  • Automatic generation of bash and zsh autocompletion scripts.
  • Internationalization of usage strings.

Basic Usage

To use rcli, add rcli to your setup_requires argument in your setup.py and set the autodetect_commands parameter to True.

.. code-block:: python

from setuptools import setup
setup(
    ...,
    install_requires=['rcli'],
    setup_requires=['rcli'],
    autodetect_commands=True,
    ...,
)

In your code, create a function with a usage string as its docstring and type hint annotations for validation.

.. code-block:: python

def repeat(message: str, num_times: int):
    """Usage: repeat <message> [--num-times <num>]

    Arguments:
        message  A message to print to the console.

    Options:
        -n, --num-times <num>  The number of times to print the message [default: 1].
    """
    for i in range(num_times):
        print(message)

Once your package is installed, a new console script repeat will be automatically generated that will validate and normalize your parameters and call your function.

Subcommand Dispatch

To generate a git-style command line interface with subcommand dispatching, you only need to create your subcommand functions and your primary command will be automatically generated for you.

.. code-block:: python

def roar():
    """Usage: cat-sounds roar"""
    print('ROAR!')

def meow():
    """Usage: cat-sounds meow"""
    print('Meow!')

This automatically generates the command cat-sounds with the following help message::

Usage:
  cat-sounds [--help] [--version] [--log-level <level> | --debug | --verbose]
             <command> [<args>...]

Options:
  -h, --help           Display this help message and exit.
  -V, --version        Display the version and exit.
  -d, --debug          Set the log level to DEBUG.
  -v, --verbose        Set the log level to INFO.
  --log-level <level>  Set the log level to one of DEBUG, INFO, WARN, or ERROR.

'cat-sounds help -a' lists all available subcommands.
See 'cat-sounds help <command>' for more information on a specific command.

.. _PEP 484: https://www.python.org/dev/peps/pep-0484/ .. _docopt: http://docopt.org/

.. |Build Status| image:: https://travis-ci.org/contains-io/rcli.svg?branch=master :target: https://travis-ci.org/contains-io/rcli .. |Coverage Status| image:: https://coveralls.io/repos/github/contains-io/rcli/badge.svg?branch=master :target: https://coveralls.io/github/contains-io/rcli?branch=master .. |PyPI| image:: https://img.shields.io/pypi/v/rcli.svg :target: https://pypi.python.org/pypi/rcli/ .. |Python Versions| image:: https://img.shields.io/pypi/pyversions/rcli.svg :target: https://pypi.python.org/pypi/rcli/ .. |Code Quality| image:: https://api.codacy.com/project/badge/Grade/61ee45c79340430793ce074748f69686 :target: https://www.codacy.com/app/contains-io/rcli?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=contains-io/rcli&amp;utm_campaign=Badge_Grade

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].