pub struct CommandSpec {
pub name: &'static str,
pub about: &'static str,
pub run: CommandFn,
pub stdio: bool,
pub offline: bool,
}Expand description
A command a module registers with ModuleBuilder::command,
run as <binary> <name> [args...] against a booted app.
Fields§
§name: &'static strThe command name, e.g. serve or queue:work.
about: &'static strA one-line description shown by help.
run: CommandFnRuns the command with the arguments after its name.
stdio: boolThe command speaks a protocol on standard output (an MCP server over
stdio, for example), so nothing else may write there: the logger
writes to standard error instead. See CommandSpec::stdio.
offline: boolThe command does not need a booted app: it runs against the module
graph, and builds only the providers it asks for. See
CommandSpec::offline.
Implementations§
Source§impl CommandSpec
impl CommandSpec
Sourcepub fn new<F, Fut>(name: &'static str, about: &'static str, f: F) -> Self
pub fn new<F, Fut>(name: &'static str, about: &'static str, f: F) -> Self
A command running f(ctx, args).
Sourcepub fn stdio(self) -> Self
pub fn stdio(self) -> Self
Marks the command as owning standard output (it writes a protocol
there). The app knows the command it runs from boot on
(AppContext::command), so modules that would print to stdout,
navree-log’s console output first among them, use stderr instead.
Sourcepub fn offline(self) -> Self
pub fn offline(self) -> Self
Marks the command as one that needs no booted app. The runner does
not build every singleton (no database connection is opened, no
server started) and runs no lifecycle hook, before or after: the
command gets the AppContext of the module graph and resolves what
it needs with AppContext::get, which builds a provider on first
use. Meant for commands that read the app’s configuration or graph,
such as config:show and config:check.