reference.cli.unknown_command
Requirements index · View definition
Example
Running
habeas unknownfails with a nonzero exit status and prints a usage message.
Rationale
tests/cli.rs#fn[unknown_command_fails_with_usage] carries a {test} reference to reference.cli.unknown_command. It runs the real habeas binary (CARGO_BIN_EXE_habeas) with the single argument unknown, which is the example’s scenario.
- Nonzero exit status:
assert!(!output.status.success())checks this.success()is false for any nonzero exit code. - Usage message printed: the test asserts that stderr contains
Usage: habeas. That checks a usage message was printed, and it fails if the command is accepted silently or errors without usage text.
The cited requirements.cli.invocation says an unknown command MUST fail with a usage message. The same test covers that part of it.
I found no gap. Two small points do not change this: the test doesn’t check the exact exit code, and success() would also be false if a signal killed the process. The example only asks for a nonzero status, so I did not count either as a gap.
Inputs
Tests
Input 3: outline tests/cli.rs fn[unknown_command_fails_with_usage]
- File:
tests/cli.rs - Selector:
fn[unknown_command_fails_with_usage] - Kind:
fn tests/cli.rs:31–41
// {test}`requirements.cli.invocation`
// {test}`reference.cli.unknown_command`
#[test]
fn unknown_command_fails_with_usage() {
let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
.arg("unknown")
.output()
.unwrap();
assert!(!output.status.success());
assert!(String::from_utf8_lossy(&output.stderr).contains("Usage: habeas"));
}
Referenced definitions
Input 2: requirements selection requirements.cli.invocation
requirements.cli.invocation:md/requirements/cli.md:561–563
:::{req} invocation
`habeas mdbook supports html` MUST succeed, and a support query for another renderer MUST fail. An unknown command or invalid setup option combination MUST fail with a usage message. In particular, `habeas agents` and `habeas setup --install-skills` MUST fail with a usage message.
:::
Other sources
Input 1: requirements selection reference.cli.unknown_command
reference.cli.unknown_command:md/reference.md:21–23
:::{example} cli.unknown_command
Running `habeas unknown` fails with a nonzero exit status and prints a usage message. {cite}`requirements.cli.invocation`
:::