feat(cli): Rich-based output, prints and debug-inventory - #1902
Open
noirbizarre wants to merge 1 commit into
Open
feat(cli): Rich-based output, prints and debug-inventory#1902noirbizarre wants to merge 1 commit into
noirbizarre wants to merge 1 commit into
Conversation
This was referenced Jul 26, 2026
noirbizarre
force-pushed
the
refactor/rich
branch
3 times, most recently
from
July 27, 2026 15:03
a0958bd to
40ce1c9
Compare
Route all human-facing CLI output through Rich, replacing Click as the output backend (Click is now removed entirely). The core stays decoupled via the pluggable `pyinfra.api.output` layer, now wired to Rich implementations. - New `pyinfra_cli.console`: shared Rich stderr console (+ stdout console for `--json`), `format_text` (click.style-compatible signature) and `echo`. - `pyinfra.api.output`: add `get_console`/`set_console`. - `main.py` wires `set_formatter(format_text)` / `set_echo(echo)`. - `prints.py`/`log.py`/`util.py`/`virtualenv.py`: Click echo/style → Rich. - `debug-inventory` renders a Rich table with per-host `key: value` data (nested values as JSON, type-coloured to match the JSON highlighter). - Unexpected errors render a Rich traceback (suppressing framework frames); the internal-error path still writes `pyinfra-debug.log`. - `--help` uses Rich formatting with a colourised usage line and a syntax-highlighted examples epilogue; the confirm prompt uses `rich.prompt`. - Core spinner switches to a shared Rich progress instance. - pyproject: remove `click`, add `rich`; keep `cyclopts`. This is the output layer only; the live progress tree follows separately.
noirbizarre
force-pushed
the
refactor/rich
branch
from
August 25, 2026 09:03
40ce1c9 to
e6ac147
Compare
noirbizarre
marked this pull request as ready for review
August 25, 2026 09:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of 3 of the CLI modernisation, split out of #1894. Part 1 (#1901, Click → Cyclopts) has merged into
3.x; this PR is rebased on top of it.Routes all human-facing CLI output through Rich, replacing Click as the output backend (Click is removed entirely). The core stays decoupled via the pluggable
pyinfra.api.outputlayer, now wired to Rich implementations.pyinfra_cli.console: shared Rich stderr console (+ stdout console for--json),format_text(click.style-compatible signature) andecho.pyinfra.api.output: addget_console/set_console.main.pywiresset_formatter(format_text)/set_echo(echo).prints.py/log.py/util.py/virtualenv.py: Click echo/style → Rich.debug-inventoryrenders a Rich table with per-hostkey: valuedata (nested values as JSON, type-coloured to match the JSON highlighter).pyinfra-debug.log.--helpuses Rich formatting with a colorized usage line and a syntax-highlighted examples epilogue; the confirm prompt usesrich.prompt.click, addrich; keepcyclopts.📚 Stacked PR series
This is one of three PRs that split the combined CLI refactor (originally #1894) into reviewable layers. They land in order; Part 3 stays in draft until the preceding part is merged.
Original combined PR (kept for reference/discussion): #1894
Related issue: #785 (use Rich) — referenced, not closed.
🎥 Showcase
Those are here to show what visually changed and what did not (yet).
In this PR,
richhas been introduced and is responsible for rendering/styling, however there is no live+tree progress.Help
Inventory
Inventory is now prettified with rich (both listing and json output). When the output is not a tty (eg. piped/redirected to something else), it is then raw json, ANSI styling do not clutter it.
Success with confirmation
Error and diff
This one show the benefit of the live+tree output coming in the next PR.
Multiline output