holger-cli/src/lib.rs
//! **holger-cli: the thin gRPC client of a Holger server** (.nornir/SUITES.md, the `cli`
//! variant; lane B3).
//!
//! The console (holger-ui) is a thin layer over holger's gRPC services, and so is this:
//! the SAME services, so every console action is a command (`table.rs`), and the server
//! decides everything exactly as it does for the console. Thin means no local database;
//! airgapped means it dials only `--at` (`conn.rs`). The credential is the person's own,
//! kept 0600 (`cred.rs`).
pub mod cli;
pub mod conn;
pub mod cred;
pub mod error;
pub mod run;
pub mod table;
/// The stubs, generated by `cargo xtask gen-proto` from holger's own `proto/` (client
/// half only). Regenerate after a proto change.
pub mod pb {
/// `holger.v1`: the product's services.
#[allow(clippy::all)]
pub mod v1 {
include!("generated/holger.v1.rs");
}
/// `holger.room.v1`.
#[allow(clippy::all)]
pub mod room {
include!("generated/holger.room.v1.rs");
}
/// `holger.account.v1`.
#[allow(clippy::all)]
pub mod account {
include!("generated/holger.account.v1.rs");
}
/// `holger.token.v1`.
#[allow(clippy::all)]
pub mod token {
include!("generated/holger.token.v1.rs");
}
/// `holger.doors.v1`: the bundle export and the first key.
#[allow(clippy::all)]
pub mod doors {
include!("generated/holger.doors.v1.rs");
}
}
pub use error::CliError;
/// Parse `args` and run the command, with `env` for the credential lookup: what `main`
/// does, callable in-process (the integration tests run every command group this way).
pub async fn run_args<I, T>(
args: I,
env: impl Fn(&str) -> Option<String>,
) -> Result<String, CliError>
where
I: IntoIterator<Item = T>,
T: Into<std::ffi::OsString> + Clone,
{
use clap::Parser as _;
let cli = cli::Cli::try_parse_from(args)
.map_err(|e| CliError::InvalidArgs(e.to_string().trim().to_owned()))?;
run::run(cli, env).await
}