GithubHelp home page GithubHelp logo

karanparikh / clize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from epsy/clize

0.0 0.0 0.0 986 KB

Clize: Command-line argument parsing for Python, without the effort

Home Page: http://clize.readthedocs.org/

License: Other

Python 100.00%

clize's Introduction

Clize procedurally turns your functions into convenient command-line interfaces.

For instance:

from sigtools.modifiers import kwoargs
from clize import run

@kwoargs('no_capitalize')
def hello_world(name=None, no_capitalize=False):
    """Greets the world or the given name.

    name: If specified, only greet this person.

    no_capitalize: Don't capitalize the given name.
    """
    if name:
        if not no_capitalize:
            name = name.title()
        return 'Hello {0}!'.format(name)
    return 'Hello world!'

if __name__ == '__main__':
    run(hello_world)

The python code above can now be used on the command-line as follows:

$ pip install clize
$ python hello.py --help
    Usage: hello.py [OPTIONS] name

    Greets the world or the given name.

    Positional arguments:
      name   If specified, only greet this person.

    Options:
      --no-capitalize   Don't capitalize the given name.

    Other actions:
      -h, --help   Show the help
$ python hello.py
Hello world!
$ python hello.py john
Hello John!
$ python hello.py dave --no-capitalize
Hello dave!

You can find the documentation at: http://clize.readthedocs.org/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.