Skip to main content

Convert functions into multi-command program breezily.

Project description

https://travis-ci.org/moskytw/clime.png https://pypip.in/v/clime/badge.png https://pypip.in/d/clime/badge.png

The full version of this documentaion is at clime.mosky.tw.

Clime

Clime lets you convert any module into a multi-command CLI program without any configuration.

The main features:

  1. It works well with zero configuration. Free you from the configuration hell.

  2. Docstrings (i.e., help texts) is just configurations. When you finish a docstring, a configuration of aliases and metavars are also finished.

  3. It generates usages for each command automatically.

It is a better choice than the heavy optparse or argparse for most of the CLI tasks.

CLI-ize ME!

Let me show you Clime with an example.

Here we have a simple script with a docstring here:

# file: repeat.py

def repeat(message, times=2, count=False):
    '''It repeats the message.

    options:
        -m=<str>, --message=<str>  The description of this option.
        -t=<int>, --times=<int>
        -c, --count
    '''

    s = message * times
    return len(s) if count else s

After add this line:

import clime.now

clime.now describes more about how to customize your program.

… your CLI program is ready!

$ python repeat.py twice
twicetwice

$ python repeat.py --times=3 thrice
thricethricethrice

It also generates a pretty usage for this script:

$ python repeat.py --help
usage: [-t<int> | --times=<int>] [-c | --count] <message>
   or: repeat [-t<int> | --times=<int>] [-c | --count] <message>

If you have a docstring in your function, it also shows up in usage manual with --help.

$ python repeat.py repeat --help
usage: [-t<int> | --times=<int>] [-c | --count] <message>
   or: repeat [-t<int> | --times=<int>] [-c | --count] <message>

It repeats the message.

options:
    -m=<str>, --message=<str>  The message.
    -t=<int>, --times=<int>
    -c, --count

You can find more examples in the clime/examples.

.Command describes more about how it works.

Installation

Clime is hosted on two different platforms, PyPI and GitHub.

Install from PyPI

Install Clime from PyPI for a stable version:

$ sudo pip install clime

If you don’t have pip, execute

$ sudo apt-get install python-pip

to install pip on Debian-base Linux distribution.

Get Clime from GitHub

If you want to follow the latest version of Clime, use

$ git clone git://github.com/moskytw/clime.git

to clone a Clime repository, or download manually from GitHub.

Project details


Download files

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

Source Distribution

clime-0.2.7.tar.gz (20.6 kB view details)

Uploaded Source

File details

Details for the file clime-0.2.7.tar.gz.

File metadata

  • Download URL: clime-0.2.7.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for clime-0.2.7.tar.gz
Algorithm Hash digest
SHA256 e01b15e616cafc495ca286127b088762ec867f0c061299066b7cbfd85d3227fc
MD5 937f90479e47dc277b11ed0726a16f93
BLAKE2b-256 55fff05dcbbec66c3ccf1bc926374b9d31574a645653a02cc1aa90b2e817c916

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page