pub struct ContractCommand {
pub wire_name: String,
pub path: Vec<String>,
pub verb: String,
pub description: String,
pub method: String,
pub http_path: String,
pub args: Vec<ContractArg>,
pub examples: Vec<ContractExample>,
}Expand description
One command: where it sits, what it is called on the wire, how it is reached over HTTP, and what it accepts.
Fields§
§wire_name: StringCanonical identity, e.g. list_agents.
path: Vec<String>Noun path from the root, e.g. ["agents", "versions"].
verb: StringLeaf verb, e.g. list.
description: String§method: StringHTTP method and path template, so a consumer holding only an API client can run the command without a hand-written implementation for it.
http_path: String§args: Vec<ContractArg>§examples: Vec<ContractExample>Worked examples, rendered under the command’s help.
Not optional in practice: a guard asserts every routed command carries
at least one, because a command surface an agent cannot learn from
--help is one it will guess at instead.
Implementations§
Source§impl ContractCommand
impl ContractCommand
Sourcepub fn after_help(&self) -> String
pub fn after_help(&self) -> String
The block rendered under a command’s help: worked examples, then the flat name the same command answers to.
Sourcepub fn clap_command(&self, display_name: &str) -> Command
pub fn clap_command(&self, display_name: &str) -> Command
The parser and the help for this command, as both consumers see it.
display_name is the spelling the caller typed, so usage and errors
read back the grammar they used rather than a wire name they did not.