diff --git a/crates/cuddle/src/main.rs b/crates/cuddle/src/main.rs index 167ab4a..70adf89 100644 --- a/crates/cuddle/src/main.rs +++ b/crates/cuddle/src/main.rs @@ -37,19 +37,15 @@ impl Cli { Self { cli, cuddle } } - pub async fn setup(self) -> anyhow::Result { - let s = self - .add_default() - .await? - .add_project_commands() - .await? - .add_plan_commands() - .await?; + pub async fn setup(mut self) -> anyhow::Result { + let commands = self.get_commands().await?; + + self.cli = self.cli.subcommands(commands); // TODO: Add global // TODO: Add components - Ok(s) + Ok(self) } pub async fn execute(self) -> anyhow::Result<()> { @@ -69,21 +65,20 @@ impl Cli { Ok(()) } - async fn add_default(mut self) -> anyhow::Result { - self.cli = self - .cli - .subcommand(clap::Command::new("do").alias("x")) - .subcommand(clap::Command::new("get")); - - Ok(self) + async fn get_commands(&self) -> anyhow::Result> { + Ok(vec![ + clap::Command::new("do").subcommand_required(true), + clap::Command::new("get"), + ]) } - async fn add_project_commands(self) -> anyhow::Result { + async fn add_project_commands(&self) -> anyhow::Result> { if let Some(_project) = self.cuddle.state.project.as_ref() { // Add project level commands + return Ok(vec![]); } - Ok(self) + Ok(Vec::new()) } async fn add_plan_commands(self) -> anyhow::Result {