Advertisement

Your Ad could be here. I want to connect my readers to relavant ads. If you have a product targeted at developers, let's talk. [email protected]

Packages

Click

Inputs

Click primarily takes two forms of inputs Options and arguments. I think of options as keyword argument and arguments as regular positional arguments.

Option

  • typically aliased with a shorthand ('-v', '--verbose')

**From the Docs

To get the Python argument name, the chosen name is converted to lower case, up to two dashes are removed as the prefix, and other dashes are converted to underscores.


@click.command()
@click.option('-s', '--string-to-echo')
def echo(string_to_echo):
    click.echo(string_to_echo)

@click.command()
@click.option('-s', '--string-to-echo', 'string')
def echo(string):
    click.echo(string)

Argument

  • positional
  • required
  • no help text supplied by click

Yaspin

Yaspin Gif

Click Help Colors

Click Help Colors Example

Colorama

Colorama Example

Click DidYouMean