Skip to main content

harmont_cli/builtin/
version.rs

1//! `hm version` — print version info, including the plugin API version
2//! and the count of loaded plugins.
3
4use anyhow::Result;
5use hm_plugin_protocol::HM_PLUGIN_API_VERSION;
6
7use crate::plugin::{PluginRegistry, RegistryConfig};
8
9// User-facing output. This is the singular purpose of this fn.
10#[allow(clippy::print_stdout)]
11// `async` is required by the dispatcher signature in `commands::dispatch`.
12#[allow(clippy::unused_async)]
13/// Run the `hm version` subcommand.
14///
15/// # Errors
16///
17/// Returns an error if the plugin registry fails to load (e.g. an
18/// invalid manifest on disk).
19pub async fn run() -> Result<()> {
20    let reg = PluginRegistry::load(RegistryConfig {
21        auto_discover: true,
22        ..Default::default()
23    })?;
24    println!("hm {}", env!("CARGO_PKG_VERSION"));
25    println!("plugin api version: {HM_PLUGIN_API_VERSION}");
26    let count = reg.manifests().count();
27    println!("plugins loaded: {count}");
28    Ok(())
29}