@@ -40,8 +40,19 @@ impl Cli {
|
||||
}
|
||||
|
||||
async fn get_commands(&self) -> anyhow::Result<Vec<clap::Command>> {
|
||||
let actions = self
|
||||
.cuddle
|
||||
.state
|
||||
.actions
|
||||
.actions
|
||||
.iter()
|
||||
.map(|a| clap::Command::new(&a.name))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok(vec![
|
||||
clap::Command::new("do").subcommand_required(true),
|
||||
clap::Command::new("do")
|
||||
.subcommand_required(true)
|
||||
.subcommands(actions.as_slice()),
|
||||
clap::Command::new("get")
|
||||
.about(GetCommand::description())
|
||||
.arg(
|
||||
@@ -67,8 +78,23 @@ impl Cli {
|
||||
.subcommand()
|
||||
.ok_or(anyhow::anyhow!("failed to find subcommand"))?
|
||||
{
|
||||
("do", _args) => {
|
||||
("do", args) => {
|
||||
tracing::debug!("executing do");
|
||||
|
||||
let (action_name, args) = args
|
||||
.subcommand()
|
||||
.ok_or(anyhow::anyhow!("failed to find do subcommand"))?;
|
||||
|
||||
let action = self
|
||||
.cuddle
|
||||
.state
|
||||
.actions
|
||||
.actions
|
||||
.iter()
|
||||
.find(|a| a.name == action_name)
|
||||
.ok_or(anyhow::anyhow!("failed to find {}", action_name))?;
|
||||
|
||||
action.call().await?;
|
||||
}
|
||||
("get", args) => {
|
||||
if !self.cuddle.has_project() {
|
||||
|
Reference in New Issue
Block a user