`lawsynth --version` and `-V` fell through to the catch-all arm and printed the multi-line usage block (exiting non-zero). Add a `version` arm that emits `lawsynth <CARGO_PKG_VERSION>` on a single line, plus a test covering the three spellings and the single-clean-line contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
22 lines
750 B
Rust
22 lines
750 B
Rust
//! The version flag must report the package version, not the usage block.
|
|
|
|
use lawsynth_cli::run;
|
|
|
|
#[test]
|
|
fn version_flags_report_the_package_version() {
|
|
let expected = format!("lawsynth {}\n", env!("CARGO_PKG_VERSION"));
|
|
for flag in ["--version", "-V", "version"] {
|
|
let output = run(&[flag.to_owned()]).expect("version flag should succeed");
|
|
assert_eq!(output, expected, "flag `{flag}` should print the version");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn version_output_is_a_single_clean_line() {
|
|
let output = run(&["--version".to_owned()]).unwrap();
|
|
// A version string, not the multi-line usage block.
|
|
assert!(output.starts_with("lawsynth "));
|
|
assert_eq!(output.lines().count(), 1);
|
|
assert!(!output.contains("usage:"));
|
|
}
|