pub mod config;
pub mod address;
pub mod port;
pub mod secret;
pub mod signature;
pub mod send;
pub mod spawn;
pub mod kill;
use clap::Subcommand;
#[derive(Subcommand)]
pub enum Commands {
Config {
#[command(subcommand)]
command: config::Commands,
},
Address {
#[command(subcommand)]
command: address::Commands,
},
Port {
#[command(subcommand)]
command: port::Commands,
},
Secret {
#[command(subcommand)]
command: secret::Commands,
},
Signature {
#[command(subcommand)]
command: signature::Commands,
},
GenerateSecretSignaturePair,
Send {
path: String,
body: String,
},
Spawn,
Kill,
}
impl Commands {
pub async fn handle(self, cli_config: &crate::Config, handle: &objectiveai_sdk::cli::output::Handle) -> Result<(), crate::error::Error> {
match self {
Commands::Config { command } => command.handle(cli_config, handle).await,
Commands::Address { command } => command.handle(cli_config, handle).await,
Commands::Port { command } => command.handle(cli_config, handle).await,
Commands::Secret { command } => command.handle(cli_config, handle).await,
Commands::Signature { command } => command.handle(cli_config, handle).await,
Commands::GenerateSecretSignaturePair => {
let pair = objectiveai_sdk::filesystem::config::generate_viewer_secret_signature_pair();
crate::config::emit_value(&pair, handle).await;
Ok(())
}
Commands::Send { path, body } => send::run(cli_config, handle, &path, &body).await,
Commands::Spawn => spawn::handle(cli_config, handle).await,
Commands::Kill => kill::handle(cli_config, handle).await,
}
}
}