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!

Donate

The Pallets organization develops and supports Flask and the libraries it uses. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today.

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.0a2.tar.gz (288.8 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.0a2-py2.py3-none-any.whl (78.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file click--hotoffthehamster-7.0.0a2.tar.gz.

File metadata

File hashes

Hashes for click--hotoffthehamster-7.0.0a2.tar.gz
Algorithm Hash digest
SHA256 c019745718c162e804f4fab21c9161711031ae2e9e98cd110f5340e078b25d93
MD5 8da626206550971cd9c8d9236cd8db20
BLAKE2b-256 7de3a02c92139b68d4d5f96b40a3a520985d6b841d152d91a5969bf7c73c3768

See more details on using hashes here.

File details

Details for the file click_hotoffthehamster-7.0.0a2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for click_hotoffthehamster-7.0.0a2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 19bde7ed5be1893fdf53458ed0017801d82e56dcbb10757fb83fc72f87db5116
MD5 2af13b129f41ad1b7ae0764ef38fabb6
BLAKE2b-256 c60224d3b2395066bcb9a0fc6e965453a072460c2891477eba9d5f4d80a59eb0

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