chore: cleanup before get
All checks were successful
continuous-integration/drone/push Build is passing

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 }
}
pub async fn setup(self) -> anyhow::Result<Self> {
let s = self
.add_default()
.await?
.add_project_commands()
.await?
.add_plan_commands()
.await?;
pub async fn setup(mut self) -> anyhow::Result<Self> {
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> {
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<Vec<clap::Command>> {
Ok(vec![
clap::Command::new("do").subcommand_required(true),
clap::Command::new("get"),
])
}
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() {
// Add project level commands
return Ok(vec![]);
}
Ok(self)
Ok(Vec::new())
}
async fn add_plan_commands(self) -> anyhow::Result<Self> {