openfunctions-rs 0.1.0

A universal framework for creating and managing LLM tools and agents
Documentation
//! Command-line interface for OpenFunctions.

use crate::core::Config;
use anyhow::Result;
use clap::{Parser, Subcommand};
use std::path::PathBuf;

mod build;
mod check;
mod test;

/// The main CLI for the OpenFunctions framework.
#[derive(Parser, Debug)]
#[command(
    name = "openfunctions",
    version,
    about = "A universal framework for creating and managing LLM tools and agents."
)]
pub struct Cli {
    /// The path to the configuration file.
    #[arg(short, long, global = true)]
    pub config: Option<PathBuf>,

    /// The subcommand to execute
    #[command(subcommand)]
    pub command: Option<Commands>,
}

/// An enumeration of the available CLI commands.
#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Build tools and agents from source.
    Build(build::BuildCommand),
    /// Check the environment and dependencies.
    Check(check::CheckCommand),
    /// Run tests for tools and agents.
    Test(test::TestCommand),
}

impl Commands {
    /// Executes the given command.
    pub async fn execute(&self, config: &Config) -> Result<()> {
        match self {
            Commands::Build(cmd) => cmd.execute(config).await,
            Commands::Check(cmd) => cmd.execute(config).await,
            Commands::Test(cmd) => cmd.execute(config).await,
        }
    }
}