Skip to main content

Crate astrs_cli

Crate astrs_cli 

Source
Expand description

The astrs binary’s library half — everything main.rs needs beyond parsing argv and choosing a process exit code (blueprint §17).

Every verb is implemented as a library-testable function under command, taking a &mut dyn std::io::Write sink and a typed args struct, returning a typed report. dispatch is the one place that maps a parsed cli::Cli onto the right command::*::run call and flattens whatever it returns into a process exit code — the only thing main.rs needs.

  single process   run                    ─► command::run     (embedded daemon)
  cluster          up · down · status     ─► command::cluster (spawns this binary)
  over the wire    start · stop · restart ─► command::lifecycle
                   destroy · clean
                   list · logs · status   ─► command::monitor
                   param get/set/list/delete ─► command::param
  local            build                  ─► command::build
                   validate · expand · graph · new · migrate ·
                   doctor · completion · schema
  hidden servers   coordinator · daemon · runtime ─► command::serve

§Every §17 verb reaches an implementation

ros2 doctor and ros2 topics were the last two that did not: the ROS 2 interop stack (astrs-rtps/astrs-ros2) landed, and both now spin a real probe participant through command::ros2. command::stub’s table is consequently empty, and it is kept as the mechanism a future wave would use again rather than as a live list.

§Read verbs and mutating verbs authenticate differently

Blueprint §16 splits the coordinator API in two, and dispatch is where that split is applied: a mutating verb (start, stop, restart, destroy, clean, param set, param delete) refuses locally when no cluster token can be found, while a read verb (list, logs, status, param get, param list) falls back to the all-zero token so a token-less development coordinator stays inspectable.

Re-exports§

pub use cli::Cli;
pub use cli::Command;
pub use error::CliError;

Modules§

cli
The astrs clap derive tree (blueprint §17): the full verb set, with a real argument schema on every subcommand — so --help, argument validation and shell completion (astrs completion) describe the whole surface, including the handful of verbs whose implementation belongs to a later wave and which report crate::error::CliError::NotImplementedYet when invoked (see crate::command::stub).
command
Library-testable command implementations, one module per verb group.
diagnostic
CliDiagnostic: the one flat, orderable diagnostic shape astrs validate renders, unifying four different upstream types (an I/O failure, astrs_manifest::ManifestError, astrs_manifest::ValidationError, astrs_manifest::expand::ExpandError and astrs_graph::Diagnostic) that otherwise share no common trait beyond Display — blueprint §17’s “human diagnostics (path, severity, colored)” and --json need one list to print, not five differently shaped error types each rendered by hand.
error
The astrs CLI’s single error type.
runtime_dir
The on-disk state astrs up creates and astrs down/astrs status read: the runtime directory, the cluster token file, and one pidfile per background process (blueprint §16, §24.2).

Functions§

dispatch
Parse, dispatch, and compute a process exit code — everything main.rs does not have to know how to do itself.