Skip to main content

Module banner

Module banner 

Expand description

Pre-flight banner emitted to stderr at the start of an analyze run.

Two purposes in one box:

  1. 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.
  2. 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 setting CLICOLOR_FORCE=1.
  • NO_COLOR respected (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-banner policy), so a piped-into-tee invocation stays clean.

Enums§

Preflight
Outcome of the pre-flight gate. Ready is 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 Duration to 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: