pub mod config;
pub mod logs;
pub mod plugins;
use clap::Subcommand;
#[derive(Subcommand)]
#[command(rename_all = "verbatim")]
pub enum Commands {
#[command(name = "list")]
List,
#[command(name = "config")]
Config {
#[command(subcommand)]
command: config::Commands,
},
#[command(name = "logs")]
Logs {
#[command(subcommand)]
command: logs::Commands,
},
#[command(name = "plugins")]
Plugins {
#[command(subcommand)]
command: plugins::Commands,
},
}
impl Commands {
pub async fn handle(self, handle: &objectiveai_cli_sdk::output::Handle) -> Result<(), crate::error::Error> {
match self {
Commands::List => {
const NAMES: &[&str] = &["config", "logs", "plugins"];
objectiveai_cli_sdk::output::Output::<objectiveai_cli_sdk::output::Schemas>::Notification(
objectiveai_cli_sdk::output::Notification {
value: objectiveai_cli_sdk::output::Schemas {
schemas: NAMES.iter().map(|s| s.to_string()).collect(),
},
},
).emit(handle).await;
Ok(())
}
Commands::Config { command } => command.handle(handle).await,
Commands::Logs { command } => command.handle(handle).await,
Commands::Plugins { command } => command.handle(handle).await,
}
}
}