Skip to content

Commit 14b5591

Browse files
committed
fix: add normalization, simplify match logic
1 parent 8658265 commit 14b5591

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/main.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,23 +266,31 @@ async fn execute_builtin_command(command: Commands) -> Result<()> {
266266
repos: if repos.is_empty() { None } else { Some(repos) },
267267
};
268268

269-
// Validate that exactly one of command or recipe is provided
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-
}
269+
// Normalize command - treat empty strings as None
270+
let command = command.filter(|s| !s.trim().is_empty());
277271

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))
272+
// Validate that exactly one of command or recipe is provided
273+
match (command.as_ref(), recipe.as_ref()) {
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+
)
284285
.execute(&context)
285286
.await?;
287+
}
288+
(None, None) => {
289+
anyhow::bail!("Either --recipe or a command must be provided");
290+
}
291+
(Some(_), Some(_)) => {
292+
anyhow::bail!("Cannot specify both command and --recipe");
293+
}
286294
}
287295
}
288296
Commands::Pr {

0 commit comments

Comments
 (0)