Skip to content

Commit

Permalink
fix: dont require run script for task add
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 18, 2024
1 parent fd9f6d1 commit 224fe54
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cli/tasks/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct TasksAdd {
#[clap(long, short)]
file: bool,

#[clap(last = true, required = true)]
#[clap(last = true)]
run: Vec<String>,
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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())?;
}
Expand Down

0 comments on commit 224fe54

Please sign in to comment.