Module banner
Expand description
Pre-flight banner emitted to stderr at the start of an analyze run.
Two purposes in one box:
- Visual preview — “you are running codelore X.Y on repo R, branch B, requesting analysis A with options O”. A human can confirm intent at a glance before the 5-30s ingest fires.
- Fail-fast gate — runs cheap pre-flight checks (path is a git repo,
HEAD has commits, output path is writable) BEFORE expensive work. On
failure the banner shows a
✗ <reason>status line with a hint, and the CLI exits non-zero without touching the ingest pipeline.
Industry-standard styling choices applied:
- stderr output. Stdout stays clean for CSV/JSON/SARIF piping.
- Auto-disable on non-TTY stderr (CI logs, file redirects). Override via
--banner(clap layer) or by settingCLICOLOR_FORCE=1. NO_COLORrespected (per https://no-color.org/) — env-var presence strips all ANSI escapes regardless of TTY status.- Unicode box drawing (
─). Assumes UTF-8 terminal — every macOS, Linux, and Windows 10+ terminal supports it. - anstyle (no allocations for color codes; same crate the cargo team uses; already in our tree transitively via clap).
Structs§
- Banner
- Data the banner needs to render. Built by the caller (CLI) from
Options+GixRepo+ pre-flight results; the banner module itself stays free of repo and clap imports so it can be snapshot-tested without spinning either up. - Footer
- Footer summary printed to stderr at the end of a successful analyze run.
Bracketing the header banner: header tells the user “this is what I’m
about to do”, footer confirms “done — here’s how long it took”. Skipped
when the header was skipped (same TTY /
--no-bannerpolicy), so a piped-into-teeinvocation stays clean.
Enums§
- Preflight
- Outcome of the pre-flight gate.
Readyis the only variant that allows the analysis to proceed; everything else aborts with a clean banner-shaped error and a non-zero exit code.
Functions§
- humanize_
duration - Convert a
Durationto a short human-readable string. Breakpoints chosen to match the cargo / pytest / npm convention: - should_
color - Decision policy for whether to colorize the banner. Mirrors cargo / clap:
- should_
print - Decision policy for whether to print the banner AT ALL. Three switches, most-restrictive wins: