Skip to main content

A simple wrapper around optparse for powerful command line utilities.

Project description

What’s Click?

Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box.

It aims to make the process of writing command line tools quick and fun while also preventing any frustration caused by the inability to implement an intended CLI API.

Click in three points:
  • arbitrary nesting of commands

  • automatic help page generation

  • supports lazy loading of subcommands at runtime

Installing

Install and update using pip:

$ pip install click

Click supports Python 3.4 and newer, Python 2.7, and PyPy

A Simple Example

What does it look like? Here is an example of a simple Click program:

import click

@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', prompt='Your name',
              help='The person to greet.')
def hello(count, name):
    """Simple program that greets NAME for a total of COUNT times."""
    for x in range(count):
        click.echo('Hello %s!' % name)

if __name__ == '__main__':
    hello()

And what it looks like when run:

$ python hello.py --count=3
Your name: John
Hello John!
Hello John!
Hello John!

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

click--hotoffthehamster-7.0.dev0.tar.gz (288.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_hotoffthehamster-7.0.dev0-py2.py3-none-any.whl (80.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file click--hotoffthehamster-7.0.dev0.tar.gz.

File metadata

File hashes

Hashes for click--hotoffthehamster-7.0.dev0.tar.gz
Algorithm Hash digest
SHA256 8b0dc0e19da37520340a47161326113e8434c364b34d29be02bbc3a6fcaf98eb
MD5 f5a197163ea8369989bcf757806ca221
BLAKE2b-256 459cb6b44df4ea4b56d9b336e98c1e97efe326de58d5f9904f33ef487816fead

See more details on using hashes here.

File details

Details for the file click_hotoffthehamster-7.0.dev0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for click_hotoffthehamster-7.0.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bceb9e00d48aec1d679fb62130bc41fcd1e02e7a115866a2011d9274ed2d74c6
MD5 76dc0792234439aee8f73ec1cb660c4f
BLAKE2b-256 4af5a02a1835413cb2df7935f3e67a777a00da4224b83a86452e814f5b3c1443

See more details on using hashes here.

Supported by

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