feat: get only in projects

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-10-24 20:24:28 +02:00
parent d33e42a608
commit dfa70b3485
Signed by: kjuulh
GPG Key ID: D85D7535F18F35FA
2 changed files with 18 additions and 0 deletions

View File

@ -54,6 +54,10 @@ impl Cli {
tracing::debug!("executing do"); tracing::debug!("executing do");
} }
("get", args) => { ("get", args) => {
if !self.cuddle.has_project() {
anyhow::bail!("get is not available without a project");
}
let query = args let query = args
.get_one::<String>("query") .get_one::<String>("query")
.ok_or(anyhow!("query is required"))?; .ok_or(anyhow!("query is required"))?;

View File

@ -66,3 +66,17 @@ impl Cuddle<PreparePlan> {
Ok(Cuddle { state }) Ok(Cuddle { state })
} }
} }
impl Cuddle<ValidatedState> {
pub fn has_project(&self) -> bool {
if self.state.project.is_some() {
return true;
}
if self.state.plan.is_some() {
return true;
}
false
}
}