openfunctions_rs/cli/
mod.rs

1//! Command-line interface for OpenFunctions.
2
3use crate::core::Config;
4use anyhow::Result;
5use clap::{Parser, Subcommand};
6use std::path::PathBuf;
7
8mod build;
9mod check;
10mod test;
11
12/// The main CLI for the OpenFunctions framework.
13#[derive(Parser, Debug)]
14#[command(
15    name = "openfunctions",
16    version,
17    about = "A universal framework for creating and managing LLM tools and agents."
18)]
19pub struct Cli {
20    /// The path to the configuration file.
21    #[arg(short, long, global = true)]
22    pub config: Option<PathBuf>,
23
24    /// The subcommand to execute
25    #[command(subcommand)]
26    pub command: Option<Commands>,
27}
28
29/// An enumeration of the available CLI commands.
30#[derive(Subcommand, Debug)]
31pub enum Commands {
32    /// Build tools and agents from source.
33    Build(build::BuildCommand),
34    /// Check the environment and dependencies.
35    Check(check::CheckCommand),
36    /// Run tests for tools and agents.
37    Test(test::TestCommand),
38}
39
40impl Commands {
41    /// Executes the given command.
42    pub async fn execute(&self, config: &Config) -> Result<()> {
43        match self {
44            Commands::Build(cmd) => cmd.execute(config).await,
45            Commands::Check(cmd) => cmd.execute(config).await,
46            Commands::Test(cmd) => cmd.execute(config).await,
47        }
48    }
49}