C0027 cli-version-line¶
Rule: --version prints the binary's name, version, git SHA and commit time.
| Code | C0027 (stable, never reused) |
| Id | cli-version-line |
| Category | cli |
| Source | spirit_level |
| Fix | by hand |
| Needs | cargo installed |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | warn |
the SHA and commit time say which build runs; older CLIs print other formats |
| small-workspace | warn |
the SHA and commit time say which build runs; older CLIs print other formats |
| medium | warn |
the SHA and commit time say which build runs; older CLIs print other formats |
| big | warn |
the SHA and commit time say which build runs; older CLIs print other formats |
| ai | off | |
| embedded | off | |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Parameters¶
| Name | Type | Default | Meaning |
|---|---|---|---|
format |
string | "{name} {version} ({sha}, commit {time})" |
the first line of --version: {name} the binary, {version}, {sha} short SHA with -dirty, {time} like 3 Oct 2026 18:20 UTC |
Why¶
--version answers "which build is this": the version alone does not say whether a fix is in. The SHA names the commit, -dirty says the tree had changes, and the commit time orders builds without a clock in the build. The name is the binary's, so a report names the tool a person types. A build from a git checkout that prints unknown has a build script that did not find git, usually because it looks for .git as a directory and the checkout is a worktree.
Example¶
How to fix¶
Use vhrd_cli's vc_build: vc_build::emit() in build.rs and #[command(version = vc_build::version!())]. A build script of its own runs git rev-parse --short HEAD, git log -1 --format=%ct and git status --porcelain, prints unknown without git, and reruns on the real git dir's HEAD and index (git rev-parse --git-dir). Only the first line is checked, so a tool may list more below it. The parameter format is the expected first line.
Configure¶
[lints.cli-version-line]
level = "deny"
format = "{name} {version} ({sha}, commit {time})"
reason = "why this project wants it at this level"
Allow one finding in the code with // spirit-level: allow(cli-version-line) <reason> (waivers); the code works there too, as in [lints.C0027].