Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

reference.cli.unknown_command

Requirements index · View definition

evidence Valid

Example

Running habeas unknown fails with a nonzero exit status and prints a usage message. cite requirements.cli.invocation

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]
// {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
:::{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
:::{example} cli.unknown_command
Running `habeas unknown` fails with a nonzero exit status and prints a usage message. {cite}`requirements.cli.invocation`
:::