pub async fn run() -> ExitCodeExpand description
Parses real CLI arguments, initializes structured logging, and runs, returning a process exit code.
Logging is resolved and initialized here rather than in [run_with_cli] – see the crate
doc comment. It reads the config file once, purely for [log] settings; run_with_cli
reads it again moments later for the database path and other settings. That small,
one-time duplication keeps run_with_cli’s own extensively unit-tested call path (which
never touches a real log directory) fully decoupled from tracing setup, which can only
ever be installed once per process. A logging setup failure (e.g. an unwritable log
directory) is deliberately non-fatal – see logging::init_tracing – so it never
prevents the actual command (and its println!-based result) from running.
cancel::CtrlC::install is called here, as the very first line, rather than inside
[run_with_cli] or anywhere later – deliberately earlier than the Ctrl+C listener’s
strict minimum requirement (registered once before the polling loop starts), so that a
Ctrl+C pressed during config loading, logging setup, database open/migrate/seed, or the
initial-readings/mode-transition sequence is also captured rather than lost or hitting
the OS default (process kill, skipping the loop restore entirely). See
safety-cancellation in AGENTS.md.