Skip to content

Commit b40fd69

Browse files
trible: --version / -V (basic CLI hygiene)
`trible --version` rejected the flag entirely: $ trible --version error: unexpected argument '--version' found That's a basic CLI hygiene gap — every `cargo install`-able tool is expected to support `--version` and `-V` for sanity-checking which build is on PATH, for bug reports, and for shell-level version pinning checks. The clap derive opts in via a single `#[command(version, ...)]` attribute on the parser. $ trible --version trible 0.36.0 $ trible -V trible 0.36.0 Locked in basic.rs with a regex match on `trible \d+\.\d+\.\d+` covering both flag forms. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d5a00e3 commit b40fd69

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

trible/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use cli::store::StoreCommand;
1313
use cli::team::Command as TeamCommand;
1414

1515
#[derive(Parser)]
16+
#[command(version, about, long_about = None)]
1617
/// A knowledge graph and meta file system for object stores.
1718
///
1819
enum TribleCli {

trible/tests/basic.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ fn completion_generates_script() {
2020
.success()
2121
.stdout(predicate::str::contains("_trible()"));
2222
}
23+
24+
#[test]
25+
fn version_flag_prints_crate_version() {
26+
// Both `--version` and `-V` flags work and print
27+
// `trible <semver>` (clap's default --version format).
28+
Command::cargo_bin("trible")
29+
.unwrap()
30+
.arg("--version")
31+
.assert()
32+
.success()
33+
.stdout(predicate::str::is_match("^trible \\d+\\.\\d+\\.\\d+\\n$").unwrap());
34+
35+
Command::cargo_bin("trible")
36+
.unwrap()
37+
.arg("-V")
38+
.assert()
39+
.success()
40+
.stdout(predicate::str::is_match("^trible \\d+\\.\\d+\\.\\d+\\n$").unwrap());
41+
}

0 commit comments

Comments
 (0)