Introduction¶

Clime lets you convert any module into a multi-command CLI program with zero configuration.
Here is a slide which introduces you to Clime:
The main features:
- It works well with zero configuration. Free you from the configuration hell.
- Docstring (i.e., help text) is just configuration. When you finish your docstring, the configuration of aliases and metavars is also finished.
- It generates usage for each command automatically.
It is a better choice than the heavy optparse or argparse for most of CLI tasks.
CLI-ize ME!¶
Let me show you Clime with an example.
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 we add this line:
import clime.now
See also
clime.now
describes more about how to customize your program.
Our 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.
See also
Command
describes more about how it works.
Installation¶
Clime is hosted on two different platforms, PyPI and GitHub.
Take a Deeper Look¶
If you want to know more about Clime, here are the details: