hivectl: make --socket a global flag instead of per-verb
The host admin socket path was duplicated on every daemon-assisted verb (agents restart/restart-all, stop, start). Hoist it to a single global arg on the top-level Cli (`--socket`, default DEFAULT_HOST_SOCKET, accepted before or after the subcommand) and thread cli.socket through dispatch. Verbs that don't talk to the daemon ignore it. Pure CLI-ergonomics change; no wire/behaviour change. Regenerated docs/tools/hivectl-cli.md.
This commit is contained in:
parent
03ea5d601b
commit
ae1bdd084a
2 changed files with 20 additions and 43 deletions
|
|
@ -34,6 +34,11 @@ recovery / debugging verbs.\
|
|||
"
|
||||
)]
|
||||
struct Cli {
|
||||
/// Path to the hive-c0re host admin socket, used by the daemon-assisted
|
||||
/// verbs (`agents`, `stop`, `start`). Global: accepted before or after
|
||||
/// the subcommand. Verbs that don't talk to the daemon ignore it.
|
||||
#[arg(long, global = true, default_value = DEFAULT_HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
#[command(subcommand)]
|
||||
cmd: Cmd,
|
||||
}
|
||||
|
|
@ -120,9 +125,6 @@ enum Cmd {
|
|||
/// the wire/CLI shape is stable when the quiesce lands.
|
||||
#[arg(long)]
|
||||
graceful: bool,
|
||||
/// Path to the hive-c0re host admin socket.
|
||||
#[arg(long, default_value = DEFAULT_HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
},
|
||||
/// Start containers hive-wide — the inverse of `hivectl stop`. Bare
|
||||
/// `hivectl start` starts everything back up; the same scope flags as
|
||||
|
|
@ -131,9 +133,6 @@ enum Cmd {
|
|||
Start {
|
||||
#[command(flatten)]
|
||||
scope: ScopeArgs,
|
||||
/// Path to the hive-c0re host admin socket.
|
||||
#[arg(long, default_value = DEFAULT_HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
},
|
||||
/// Emit the full CLI reference as `CommonMark` to stdout.
|
||||
///
|
||||
|
|
@ -369,19 +368,12 @@ enum AgentsCmd {
|
|||
Restart {
|
||||
/// Agent name (e.g. `damocles`, `ruth`).
|
||||
name: String,
|
||||
/// Path to the hive-c0re host admin socket.
|
||||
#[arg(long, default_value = DEFAULT_HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
},
|
||||
/// Stop and restart ALL managed agent containers in sequence.
|
||||
/// Iterates the live container list and restarts each one. Any per-agent
|
||||
/// failure is reported at the end rather than stopping mid-run, so all
|
||||
/// containers get a restart attempt.
|
||||
RestartAll {
|
||||
/// Path to the hive-c0re host admin socket.
|
||||
#[arg(long, default_value = DEFAULT_HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
},
|
||||
RestartAll,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -393,6 +385,7 @@ async fn main() -> Result<()> {
|
|||
)
|
||||
.init();
|
||||
let cli = Cli::parse();
|
||||
let socket = cli.socket;
|
||||
match cli.cmd {
|
||||
Cmd::Forge { cmd } => match cmd {
|
||||
ForgeCmd::CreateUser {
|
||||
|
|
@ -423,15 +416,11 @@ async fn main() -> Result<()> {
|
|||
GatewayCmd::ListUsers { file } => gateway_list_users(&file),
|
||||
},
|
||||
Cmd::Agents { cmd } => match cmd {
|
||||
AgentsCmd::Restart { name, socket } => agents_restart(&socket, &name).await,
|
||||
AgentsCmd::RestartAll { socket } => agents_restart_all(&socket).await,
|
||||
AgentsCmd::Restart { name } => agents_restart(&socket, &name).await,
|
||||
AgentsCmd::RestartAll => agents_restart_all(&socket).await,
|
||||
},
|
||||
Cmd::Stop {
|
||||
scope,
|
||||
graceful,
|
||||
socket,
|
||||
} => stop(&socket, scope.to_scope(), graceful).await,
|
||||
Cmd::Start { scope, socket } => start(&socket, scope.to_scope()).await,
|
||||
Cmd::Stop { scope, graceful } => stop(&socket, scope.to_scope(), graceful).await,
|
||||
Cmd::Start { scope } => start(&socket, scope.to_scope()).await,
|
||||
Cmd::Choom { name, fresh } => choom(&name, fresh),
|
||||
Cmd::MarkdownDocs => {
|
||||
print!("{}", clap_markdown::help_markdown::<Cli>());
|
||||
|
|
|
|||
Loading…
Reference in a new issue