diff --git a/website/data/category_intros/cli-development.md b/website/data/category_intros/cli-development.md index e8a0a153..3b4e4079 100644 --- a/website/data/category_intros/cli-development.md +++ b/website/data/category_intros/cli-development.md @@ -5,11 +5,12 @@ How to choose: - Basic command-line app with no dependencies: argparse - Nested commands, or subcommands loaded lazily: Click - Options declared once as type-hinted function parameters: Typer -- Interactive prompts and REPLs: prompt_toolkit - Help text read from your docstrings: cyclopts - Progress bar for a loop: tqdm, or alive-progress for animated bars - Colored text, tables, and logs: Rich, or colorama for ANSI colors on Windows +- ASCII-art banners: pyfiglet - Full-screen app in the terminal or a browser: Textual +- Interactive prompts and REPLs: prompt_toolkit - Terminal widgets on an event loop you already run: Urwid - Full-screen forms and ASCII animations: asciimatics @@ -19,8 +20,6 @@ Click builds a CLI from [commands declared with decorators](https://click.pallet Typer builds a CLI from your function signatures: you [declare each argument and option once](https://typer.tiangolo.com/), as a type-hinted function parameter. Write those hints with `Annotated`, which its tutorial [recommends wherever possible](https://typer.tiangolo.com/tutorial/arguments/optional/). Its docs say you get [the best results by pairing it with Rich](https://typer.tiangolo.com/tutorial/printing/): Typer structures the commands and options, and Rich displays the output. -prompt_toolkit is for interactive input. It can [replace GNU readline](https://python-prompt-toolkit.readthedocs.io/en/stable/) or build full-screen apps. For a REPL, use a [`PromptSession`](https://python-prompt-toolkit.readthedocs.io/en/stable/pages/asking_for_input.html), which keeps the history for the whole session. - cyclopts also builds a CLI from type-hinted functions, but reads the help text from your docstrings. Its docs call that [the preferred way to document a command](https://cyclopts.readthedocs.io/en/latest/commands.html), and reach for `Annotated` with `Parameter` only when you need more control. It follows Python's own argument binding rules, so a parameter can be passed [by position or as a keyword](https://cyclopts.readthedocs.io/en/latest/vs_typer/positional_or_keyword/README.html). It has its own parser, with no Click underneath. Register commands with `@app.command`, and the function to run when no command matches with [`@app.default`](https://cyclopts.readthedocs.io/en/latest/getting_started.html). tqdm adds a progress bar to any loop: [wrap the iterable in `tqdm()`](https://github.com/tqdm/tqdm). Import it from `tqdm.auto`, which picks the console bar or the Jupyter widget for you. alive-progress wraps the loop in an [`alive_bar` context manager](https://github.com/rsalmei/alive-progress) instead, with a spinner that speeds up and slows down with your throughput. @@ -29,8 +28,12 @@ Rich writes colored text, tables, Markdown, and syntax-highlighted code to the t colorama makes ANSI escape codes work on Windows and does nothing on other platforms. If that's all you need, call [`just_fix_windows_console()`](https://github.com/tartley/colorama). +pyfiglet is [a full port of FIGlet into pure Python](https://github.com/pwaller/pyfiglet): it renders text in ASCII-art fonts, as in `pyfiglet.figlet_format("text", font="slant")`. + Textual apps run in the terminal, and the `textual serve` command from textual-dev [serves them in a browser](https://textual.textualize.io/guide/devtools/). Build one by [subclassing `App`](https://textual.textualize.io/guide/app/), and style its widgets with [CSS](https://textual.textualize.io/guide/CSS/). +prompt_toolkit is for interactive input. It can [replace GNU readline](https://python-prompt-toolkit.readthedocs.io/en/stable/) or build full-screen apps. For a REPL, use a [`PromptSession`](https://python-prompt-toolkit.readthedocs.io/en/stable/pages/asking_for_input.html), which keeps the history for the whole session. + Urwid is a [console widget construction set](https://urwid.org/manual/overview.html) rather than a finished UI library. It runs on [your choice of event loop](https://github.com/urwid/urwid): asyncio, or another one you already use. It's [licensed under the LGPL](https://github.com/urwid/urwid/blob/master/COPYING), while Textual and asciimatics use permissive licenses. asciimatics does [full-screen text UIs, from interactive forms to ASCII animations](https://github.com/peterbrittain/asciimatics): create a Screen, build a Scene from Effect objects, and let the Screen play it.