Skip to content

Commit 8658265

Browse files
committed
fix: simpler validation
1 parent ffa51b6 commit 8658265

1 file changed

Lines changed: 14 additions & 22 deletions

File tree

src/main.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -267,30 +267,22 @@ async fn execute_builtin_command(command: Commands) -> Result<()> {
267267
};
268268

269269
// Validate that exactly one of command or recipe is provided
270-
match (command.as_ref(), recipe.as_ref()) {
271-
(Some(cmd), None) if cmd.trim().is_empty() => {
272-
anyhow::bail!("Either --recipe or a command must be provided");
273-
}
274-
(Some(cmd), None) => {
275-
RunCommand::new_command(cmd.clone(), no_save, output_dir.map(PathBuf::from))
276-
.execute(&context)
277-
.await?;
278-
}
279-
(None, Some(recipe_name)) => {
280-
RunCommand::new_recipe(
281-
recipe_name.clone(),
282-
no_save,
283-
output_dir.map(PathBuf::from),
284-
)
270+
if command.is_none() && recipe.is_none() {
271+
anyhow::bail!("Either --recipe or a command must be provided");
272+
}
273+
274+
if command.is_some() && recipe.is_some() {
275+
anyhow::bail!("Cannot specify both command and --recipe");
276+
}
277+
278+
if let Some(cmd) = command {
279+
RunCommand::new_command(cmd, no_save, output_dir.map(PathBuf::from))
280+
.execute(&context)
281+
.await?;
282+
} else if let Some(recipe_name) = recipe {
283+
RunCommand::new_recipe(recipe_name, no_save, output_dir.map(PathBuf::from))
285284
.execute(&context)
286285
.await?;
287-
}
288-
(None, None) => {
289-
anyhow::bail!("Either --recipe or a command must be provided");
290-
}
291-
(Some(_cmd), Some(_recipe_name)) => {
292-
anyhow::bail!("Cannot specify both command and --recipe");
293-
}
294286
}
295287
}
296288
Commands::Pr {

0 commit comments

Comments
 (0)