Skip to main content

Module commands

Module commands 

Source
Expand description

Command dispatch: the one place a parsed command line becomes a call.

Each command is a function from its own argument type to an exit code, and run is the only mapping between the two. That is the whole of what lives here — no argument is interpreted, no repository is opened, nothing is rendered. A command that does more than render is a command that has taken business logic out of the capability it should be calling: the modules below reach the registry through Context::execute, the same call MCP and the HTTP routes make, so a command cannot answer differently from the API.

§The exit-code contract

Ok(0) is success. A command that decides a verdict answers with the code for it — 10 for a contract unmet, which scope --check and quality report both use. An Err carries its own code through crate::Error::exit_code, so a failure has one code whether the command chose it or an error did.

§Which commands are here, and which are not

A command is the projection of a capability, or crate::cli::local says why it is not. Both are checked by crate::quality::parity. Nothing in this module decides it.

use majordomus_cli::cli::{Cli, Command};
use clap::Parser;

// dispatch is total over the command line: every variant clap can parse has an arm
let cli = Cli::try_parse_from(["majordomus", "quality", "report", "--summary"]).unwrap();
assert!(matches!(cli.command, Command::Quality(_)));

Functions§

run
Run the selected command. Ok(0) is success; an Err carries its own exit code.