From 224fe54bd8123cc22cfeaf726aecd030d81755ba Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 18 Dec 2024 07:11:00 -0600 Subject: [PATCH] fix: dont require run script for `task add` --- src/cli/tasks/add.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cli/tasks/add.rs b/src/cli/tasks/add.rs index 0cfa1e9ac..d05750386 100644 --- a/src/cli/tasks/add.rs +++ b/src/cli/tasks/add.rs @@ -61,7 +61,7 @@ pub struct TasksAdd { #[clap(long, short)] file: bool, - #[clap(last = true, required = true)] + #[clap(last = true)] run: Vec, } @@ -116,8 +116,10 @@ impl TasksAdd { } lines.push("set -euxo pipefail".into()); lines.push("".into()); - lines.push(self.run.join(" ")); - lines.push("".into()); + if !self.run.is_empty() { + lines.push(self.run.join(" ")); + lines.push("".into()); + } file::create_dir_all(path.parent().unwrap())?; file::write(&path, lines.join("\n"))?; } else { @@ -197,7 +199,9 @@ impl TasksAdd { if self.silent { task.insert("silent", true.into()); } - task.insert("run", shell_words::join(&self.run).into()); + if !self.run.is_empty() { + task.insert("run", shell_words::join(&self.run).into()); + } tasks.insert(&self.task, Item::Table(task)); file::write(path, doc.to_string())?; }