skip to navigation
skip to content

cliar 1.1.6

Cliar lets you create powerful commandline interfaces from regular Python classes. Using type hints, you can add validation and on-the-fly parsing.

Create CLIs from Python classes. Make them powerful with type hints.

Cliar is a Python tool that helps you create commandline interfaces:

from cliar import CLI

class Git(CLI):
    '''Git clone created with Cliar'''

    def clone(self, repo, dir='.'):
        '''Clone a git repo from REPO to DIR.'''

        print('Cloning from %s to %s' % (repo, dir))

if __name__ == '__main__':
    Git().parse()

Run the script:

$ python git.py clone http://foo.bar -d baz
Cloning from http://foo.bar to baz

Requirements

Cliar runs with Python 3.5+ on Windows, Linux, and Mac. There are no external dependencies.

Install

Install Cliar from PyPI with pip:

$ pip install cliar

You can install Cliar on CentOS 6 with yum from Gleb Goncharov’s public repo:

$ yum install -y python-cliar

Hello World

from cliar import CLI


class Hello(CLI):
    def hello(self, name='world'):
        print('Hello ' + name + '!')

if __name__ == '__main__':
    Hello().parse()
python hello.py hello --name Bob
Hello Bob!

Limitations

Cliar is designed to help you create CLIs quickly. For the sake of simplicity, some features are unavailable:

  • You can’t add help text for individual arguments. You can add help text for individual commands with docstrings though.
  • You can’t have 3rd-level commands.
 
File Type Py Version Uploaded on Size
cliar-1.1.6-py3-none-any.whl (md5) Python Wheel 3.6 2017-10-16 5KB
cliar-1.1.6.tar.gz (md5) Source 2017-10-16 4KB