Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Python Libraries for Building Command Line Applications

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comparison of argparse, Click and Typer

I personally prefer argparse. For simpler examples, typer (which vendors click) is elegant. However, when you need customization and flexibility, it becomes a mess.

Aspect

argparse

Click

Typer

Standard library

Yes, built into Python

No, third-party (pip install click)

No, third-party (pip install typer), built on top of Click

API style

Imperative: build a ArgumentParser and call add_argument

Decorator-based: @click.command, @click.option/@click.argument

Decorator-based with type hints: plain function signatures with Python type annotations

Type inference

No, types specified explicitly via type=

Partial, types specified explicitly via type=

Yes, types and defaults inferred automatically from function signatures

Boilerplate for simple CLIs

High

Medium

Low

Subcommands

Supported via add_subparsers, verbose

Supported via click.Group, concise

Supported by composing multiple functions/Typer apps, concise

Automatic help generation

Yes, basic

Yes, richer formatting

Yes, richer formatting (colorized output via Rich if installed)

Shell completion

No built-in support

Yes, built-in support for Bash/Zsh/Fish

Yes, built-in support for Bash/Zsh/Fish/PowerShell

Testing utilities

No built-in support

Yes, click.testing.CliRunner

Yes, typer.testing.CliRunner (wraps Click’s)

Ecosystem/plugins

None

Large, many extensions (e.g. click-plugins, Flask CLI)

Growing, inherits Click’s ecosystem

Learning curve

Low, familiar to most Python developers

Medium

Low, especially for developers already using type hints

Best fit

Small scripts, avoiding extra dependencies

Complex CLIs needing fine-grained control and a mature plugin ecosystem

Modern CLIs prioritizing developer ergonomics and type-hint-driven design