mod bundle;
mod install;
#[cfg(test)]
mod commands;
#[cfg(test)]
mod extract;
pub use bundle::{Installed, Listed, Shown};
use crate::outcome::Outcome;
use anyhow::Result;
use bundle::SkillName;
use clap::Subcommand;
use clap::builder::{PathBufValueParser, TypedValueParser};
use install::InstallDir;
#[derive(Debug, Subcommand)]
pub enum SkillsCommand {
List,
Show {
#[arg(long, value_name = "NAME")]
name: SkillName,
},
Install {
#[arg(long, value_name = "DIR", value_parser = PathBufValueParser::new().try_map(InstallDir::try_from))]
into: InstallDir,
},
}
pub fn run(command: SkillsCommand) -> Result<Outcome> {
match command {
SkillsCommand::List => Ok(Outcome::SkillsListed(Listed::embedded())),
SkillsCommand::Show { name } => Ok(Outcome::SkillsShown(Shown::from(name))),
SkillsCommand::Install { into } => Ok(Outcome::SkillsInstalled(install::install(into)?)),
}
}