openfunctions_rs/cli/
check.rs

1//! The `check` command for verifying the environment and dependencies.
2
3use crate::core::{Checker, Config};
4use anyhow::Result;
5use clap::Args;
6
7/// A command for checking the environment and dependencies.
8#[derive(Args, Debug)]
9pub struct CheckCommand {
10    /// The specific target to check (a tool or agent name).
11    /// If not provided, the entire environment will be checked.
12    pub target: Option<String>,
13}
14
15impl CheckCommand {
16    /// Executes the `check` command.
17    pub async fn execute(&self, config: &Config) -> Result<()> {
18        let checker = Checker::new(config);
19        if let Some(target) = &self.target {
20            checker.check_target(target).await?;
21        } else {
22            checker.check_all().await?;
23        }
24        Ok(())
25    }
26}