Building Cli apps in Python

edit ✏️

toc

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


**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

Yaspin

Yaspin Gif

Click Help Colors

Click Help Colors Example

Colorama

Colorama Example

Click DidYouMean