use std::path::PathBuf;
use anyhow::Result;
use clap::Subcommand;
use crate::commands;
#[derive(Debug, Subcommand)]
pub enum SkillsAction {
List(ScopeArgs),
Init(InitArgs),
}
#[derive(Debug, clap::Args)]
pub struct ScopeArgs {
#[arg(long, short = 'g')]
pub global: bool,
}
#[derive(Debug, clap::Args)]
pub struct InitArgs {
pub name: String,
#[arg(long, short = 'o')]
pub output: Option<PathBuf>,
}
pub fn run(action: SkillsAction, output: &crate::output::Output) -> Result<()> {
match action {
SkillsAction::List(args) => {
output.emit(&commands::skills_list(args.global)?)?;
Ok(())
}
SkillsAction::Init(args) => {
let target = args
.output
.unwrap_or_else(|| PathBuf::from(&args.name).join("SKILL.md"));
output.emit(&commands::skills_init(&args.name, &target)?)?;
Ok(())
}
}
}