use clap::Subcommand;
use objectiveai_sdk::cli::output::{Handle, Notification, Output};
#[derive(Subcommand)]
pub enum Commands {
Github(GithubArgs),
Filesystem,
}
#[derive(clap::Args)]
pub struct GithubArgs {
#[arg(long)]
pub owner: String,
#[arg(long)]
pub repository: String,
#[arg(long)]
pub commit_sha: Option<String>,
#[arg(long)]
pub allow_untrusted: bool,
#[arg(long)]
pub upgrade: bool,
}
impl Commands {
pub async fn handle(
self,
cli_config: &crate::Config,
handle: &Handle,
) -> Result<(), crate::error::Error> {
match self {
Commands::Github(args) => {
super::install(
cli_config,
handle,
&args.owner,
&args.repository,
args.commit_sha.as_deref(),
args.allow_untrusted,
args.upgrade,
)
.await
}
Commands::Filesystem => emit_instructions(handle).await,
}
}
}
#[derive(serde::Serialize)]
struct Instructions {
instructions: String,
}
async fn emit_instructions(handle: &Handle) -> Result<(), crate::error::Error> {
let instructions = include_str!(
"../../assets/plugins/install/filesystem/INSTRUCTIONS.md"
)
.to_string();
Output::<Instructions>::Notification(Notification {
value: Instructions { instructions },
})
.emit(handle)
.await;
Ok(())
}