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.dev1.tar.gz (290.0 kB view details)

Uploaded Source

Built Distribution

click_hotoffthehamster-7.0.dev1-py2.py3-none-any.whl (78.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for click--hotoffthehamster-7.0.dev1.tar.gz
Algorithm Hash digest
SHA256 c405b9967c2fc07087c59b4f6d0e71f545401e45ab126b4e5cd3b62a75c5b0c9
MD5 4b97f3aa6f0752d4fdad44f2e74a522a
BLAKE2b-256 f8d4235d5fa5d1329c1272443cae1712fb337cb5acf6ad7f6677cfea609b8227

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for click_hotoffthehamster-7.0.dev1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 408a7c637009d7283d60cab4e63ebbe0dd10d05cb4d1141a49e7d7a6284456d9
MD5 6450222a9490f00fa3601a592bacb5de
BLAKE2b-256 01a9ad334b93ba23c219d6523134cd4e66cd818b051b9b25a03d0ef6c3ce87b7

See more details on using hashes here.

Supported by

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