Overview

Click 8.0, released on May 11, 2021, is a major release with significant API changes and Python 3 only support.

Main Features

API changes

Click 8.0 drops Python 2, changes file handling (lazy opening by default), and improves the color system.

python
import click

@click.command()
@click.option('--name', prompt='Your name')
@click.option('--count', default=1, type=int)
def hello(name: str, count: int):
    for _ in range(count):
        click.echo(f'Hello {name}!')

if __name__ == '__main__':
    hello()

Shell completion

The shell completion system is overhauled with native support for Bash, Zsh, and Fish.

python
import click

@click.command()
@click.option(
    '--color',
    type=click.Choice(['red', 'green', 'blue']),
    help='Color to use',
)
def paint(color):
    click.secho(f'Color: {color}', fg=color)

# Activation: eval "$(_PAINT_COMPLETE=bash_source paint)"

Sources