chore: cleanup before get

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-08-25 21:08:34 +02:00
parent b3aedfb411
commit 23d68caf71
Signed by: kjuulh
GPG Key ID: D85D7535F18F35FA

View File

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