Watch
0
0
Fork
You've already forked hyperhive
0

hivectl: the open verb is gone and the docs say what hivectl has

This commit is contained in:
damocles 2026-11-06 23:37:12 +01:00 • committed by mara
commit 06b303aff2
3 changed files with 7 additions and 139 deletions

View file

@ -126,15 +126,6 @@ pub enum Cmd {
#[arg(long)]
graceful: bool,
},
/// Print (and best-effort open in a browser) a hive web surface URL.
///
/// Resolves the URL from the running daemon so custom forge / matrix
/// domains work. Bare `hivectl open` opens the operator dashboard.
Open {
/// Which surface to open. Defaults to the operator dashboard.
#[arg(value_enum, default_value_t = OpenTarget::Home)]
target: OpenTarget,
},
/// Emit the full CLI reference as `CommonMark` to stdout.
///
/// Hidden tooling command used by the docs build to keep the published
@ -153,17 +144,6 @@ pub enum Cmd {
},
}
/// Which hive web surface `hivectl open` targets.
#[derive(Copy, Clone, Debug, clap::ValueEnum)]
pub enum OpenTarget {
/// The operator dashboard (`https://<hive>.hives.<swarm domain>/`).
Home,
/// The forge (Forgejo) web UI.
Forge,
/// The matrix GUI (fluffychat).
Matrix,
}
/// Shared scope flags for `hivectl stop` / `start` / `restart`. With no
/// flag set the verb targets **everything** (all sub-agents + the
/// gateway). Setting any flag restricts to the selected classes,

View file

@ -31,8 +31,6 @@ mod completions;
mod quota;
mod util;
use completions::generate_completions;
mod open;
use open::open_url;
mod wg;
use wg::{peer_config, require_hive_domain, wg_init, wg_peer, wg_status};
mod agents;
@ -93,7 +91,6 @@ async fn main() -> Result<()> {
print!("{}", clap_markdown::help_markdown_custom::<Cli>(&options));
Ok(())
}
Cmd::Open { target } => open_url(&socket, target).await,
Cmd::Completions { shell } => {
generate_completions(shell);
Ok(())

View file

@ -1,46 +0,0 @@
//! `hivectl open <home|forge|matrix>` — resolve a hive surface URL from the
//! daemon, print it, and best-effort `xdg-open` it.
use std::path::Path;
use anyhow::{Context as _, Result};
use crate::cli::OpenTarget;
use crate::util::query_hive_urls;
/// `open <home|forge|matrix>` — resolve the surface URL from the daemon,
/// print it, then best-effort `xdg-open` it. Printing is the reliable
/// core (headless / SSH hosts where no browser opener exists); the open
/// is convenience on top, so a missing/failed `xdg-open` is not an error.
pub(crate) async fn open_url(socket: &Path, target: OpenTarget) -> Result<()> {
// The connect error is already actionable (`client::request` classifies
// it), so propagate it rather than restating a guess about the cause.
let urls = query_hive_urls(socket)
.await
.context("could not read this hive's URLs from the daemon")?
.context("the daemon reported no URLs — `services.hyperhive.domain` is unset")?;
let (url, hint) = match target {
OpenTarget::Home => (
urls.home,
"the dashboard URL needs `services.hyperhive.swarm.domain` set and this hive in `swarm.hives`",
),
OpenTarget::Forge => (
urls.forge,
"the public forge URL needs `services.hyperhive.swarm.forge.publicUrl` to be set",
),
OpenTarget::Matrix => (
urls.matrix,
"the matrix GUI URL needs `services.hyperhive.swarm.matrix.gatewayHost` set",
),
};
let url = url.with_context(|| format!("no URL available for this surface — {hint}"))?;
println!("{url}");
// Best-effort: many hosts are headless, so a missing opener or a
// non-zero exit is fine — the URL is already printed.
match std::process::Command::new("xdg-open").arg(&url).status() {
Ok(status) if status.success() => {}
Ok(status) => eprintln!("note: xdg-open exited with {status} (URL printed above)"),
Err(e) => eprintln!("note: could not run xdg-open ({e}) (URL printed above)"),
}
Ok(())
}