Skip to main content

A easy-to-use command-line interface generator

Project description

Groom, is an easy-to-use command-line application framework.

This module defines an even much easier way to make user-friendly command-line interfaces than any others else. Once you define a function as the entry point of your application, Groom will automatically detect how to parse sys.argv and apply it to your application. Groom also generates help and usage messages and issue errors when users set invalid arguments to your application.


Have you never wanted to create CLI tools with python more easily? Groom brings you an easier way to create CLI tools.

Here is an example:

import sys
from groom import positional, optional, Dispatcher

__version__ = '1.0'

def calculate(
    num1: positional(float, "former number", required=True, var_name='N1'),
    num2: positional(float, "latter number", required=True, var_name='N2'),
    operator: optional(str, "operator name", short_name='op')='add'):
  if operator == 'add':
    print(num1 + num2)
  if operator == 'sub':
    print(num1 - num2)
  if operator == 'mul':
    print(num1 * num2)
  if operator == 'div':
    print(num1 / num2)
  print("unknown operator:", operator, file=sys.stderr)

if __name__ == '__main__':
    "calculate one of four arithmetic operations"

…and then, you can call the program like this:

$ python 1 2 -op div

Once you call this program with -h or --help, Groom displays the help messages:

$ python -h 1.0

calculate one of four arithmetic operations

Usage: [-v | --version | -h | --help] <N1> <N2>
    [--operator <OPERATOR> | -op <OPERATOR>]

positional parameters:
  former number
  type: float
  required: True
  latter number
  type: float
  required: True

--operator, -op:
  operator name
  type: str
  required: False
  multiple values: False
  default: add

Groom can handle 6 primitive types such as str, int, float, complex and bool and list of those types. If you specify another as a parameter type, Groom will throw TypeError.

Groom is licensed under the MIT License, for further details see LICENSE.txt.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for groom, version 0.1.0b1
Filename, size File type Python version Upload date Hashes
Filename, size groom-0.1.0b1.tar.gz (8.4 kB) File type Source Python version None Upload date Hashes View
Filename, size groom-0.1.0b1-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page