<commit_before>Clime
=====

**Note**: The 0.1.4 is a rewrote version and it does **not** provide backward compatibility.

Clime let you convert a module, a dict or an instance into a multi-command CLI
program.

It scans the object to find the functions out, so it is **low couple** with
your source.

And, it scan the aliases and metavars of options from docstring, so you are free
from writing the settings of options. You can focus on writing the help text of
your CLI program.

It is a better choice than the heavy `optparse` or `argparse` for simple CLI tasks.

Let me show an example for you.

See the full documentaion on http://docs.mosky.tw/clime/ .

CLI-ize ME!
-----------

Here we have a simple script with docstring here: ::

    # filename: repeat.py
    
    def repeat(string, time=2):
        '''repeat string n times

        options:
            -n N, --time N  repeat N times.
        '''
        
        print string * time

After add this line, ::

    import clime.now

... you now have a CLI program! ::
    
    $ python repeat.py twice
    twice
    twice

    $ python repeat.py -n3 thrice
    thrice
    thrice
    thrice

And it gerneate the usage from your function: ::

    $ python repeat.py --help
    usage: [--time N | -n N] STRING
       or: repeat [--time N | -n N] STRING

If you wrote a docstring, it will also show up in help text. ::

    $ python repeat.py repeat --help
    usage: [--time N | -n N] STRING
       or: repeat [--time N | -n N] STRING

    repeat string n times

    options:
        -n N, --time N  repeat N times.
    
You can find more examples in the `clime/examples`_.

See `Command.scan`_ for more details about argument parsing.

.. _`clime/examples`:
    https://github.com/moskied/clime/tree/master/examples
    
.. _`Command.scan`:
    http://docs.mosky.tw/clime/deeper.html#clime.Command.scan

Installation
------------

Clime is hosted on two different platforms, PyPI_ and GitHub_.

1. **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.

2. **Get Clime from GitHub**
   
   If you want to follow the lastest version of Clime, use ::
   
     $ git clone git://github.com/moskied/clime.git
     
   to clone a Clime repository. Or download manually from GitHub_.

.. _GitHub:
    http://github.com/moskied/clime

.. _PyPI:
    http://pypi.python.org/pypi/clime

Usage
-----

Here is the basic usage of Clime.

You have two different ways to use Clime.

1. **Insert A Line into Your Source**
   
   Just add this line into your source ::
   
     import clime.now
   
   It is recommend to put the codes into the ``if __name__ == '__main__':`` block.

2. **Use Clime as A Command**
   
   `clime` is also an executable module. Use it to convert a module or a
   Python file temporarily. ::
   
     $ python -m clime TARGET

See `clime.Program`_ for more usages.

.. _`clime.Program`:
    http://docs.mosky.tw/clime/deeper.html#clime.Program

More Details
------------

These are the basics of Clime usage. If you want to know more, details are here:

.. _`Take a Deeper Look at Clime`:
    http://docs.mosky.tw/clime/deeper.html<commit_msg>add the link of deeper<commit_after>Clime
=====

**Note**: The 0.1.4 is a rewrote version and it does **not** provide backward compatibility.

Clime let you convert a module, a dict or an instance into a multi-command CLI
program.

It scans the object to find the functions out, so it is **low couple** with
your source.

And, it scan the aliases and metavars of options from docstring, so you are free
from writing the settings of options. You can focus on writing the help text of
your CLI program.

It is a better choice than the heavy `optparse` or `argparse` for simple CLI tasks.

Let me show an example for you.

See the full documentaion on http://docs.mosky.tw/clime/ .

CLI-ize ME!
-----------

Here we have a simple script with docstring here: ::

    # filename: repeat.py
    
    def repeat(string, time=2):
        '''repeat string n times

        options:
            -n N, --time N  repeat N times.
        '''
        
        print string * time

After add this line, ::

    import clime.now

... you now have a CLI program! ::
    
    $ python repeat.py twice
    twice
    twice

    $ python repeat.py -n3 thrice
    thrice
    thrice
    thrice

And it gerneate the usage from your function: ::

    $ python repeat.py --help
    usage: [--time N | -n N] STRING
       or: repeat [--time N | -n N] STRING

If you wrote a docstring, it will also show up in help text. ::

    $ python repeat.py repeat --help
    usage: [--time N | -n N] STRING
       or: repeat [--time N | -n N] STRING

    repeat string n times

    options:
        -n N, --time N  repeat N times.
    
You can find more examples in the `clime/examples`_.

See `Command.scan`_ for more details about argument parsing.

.. _`clime/examples`:
    https://github.com/moskied/clime/tree/master/examples
    
.. _`Command.scan`:
    http://docs.mosky.tw/clime/deeper.html#clime.Command.scan

Installation
------------

Clime is hosted on two different platforms, PyPI_ and GitHub_.

1. **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.

2. **Get Clime from GitHub**
   
   If you want to follow the lastest version of Clime, use ::
   
     $ git clone git://github.com/moskied/clime.git
     
   to clone a Clime repository. Or download manually from GitHub_.

.. _GitHub:
    http://github.com/moskied/clime

.. _PyPI:
    http://pypi.python.org/pypi/clime

Usage
-----

Here is the basic usage of Clime.

You have two different ways to use Clime.

1. **Insert A Line into Your Source**
   
   Just add this line into your source ::
   
     import clime.now
   
   It is recommend to put the codes into the ``if __name__ == '__main__':`` block.

2. **Use Clime as A Command**
   
   `clime` is also an executable module. Use it to convert a module or a
   Python file temporarily. ::
   
     $ python -m clime TARGET

See `clime.Program`_ for more usages.

.. _`clime.Program`:
    http://docs.mosky.tw/clime/deeper.html#clime.Program

More Details
------------

These are the basics of Clime usage. If you want to know more, details are here: `Take a Deeper Look at Clime`_

.. _`Take a Deeper Look at Clime`:
    http://docs.mosky.tw/clime/deeper.html
{'fraction_non_alphanumeric': 0.10392333033842467, 'fraction_numerical': 0.0026954177897574125, 'mean_word_length': 2.371529530540131, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3648428', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2085, 'n_words': 871}