Skip to content

Commit

Permalink
add --parallel command line argument
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Mar 5, 2023
1 parent d6fb65d commit c21d46a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) struct Config {
pub(crate) list_heading: String,
pub(crate) list_prefix: String,
pub(crate) load_dotenv: bool,
pub(crate) parallel: bool,
pub(crate) search_config: SearchConfig,
pub(crate) shell: Option<String>,
pub(crate) shell_args: Option<Vec<String>>,
Expand Down Expand Up @@ -94,6 +95,7 @@ mod arg {
pub(crate) const LIST_PREFIX: &str = "LIST-PREFIX";
pub(crate) const NO_DOTENV: &str = "NO-DOTENV";
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
pub(crate) const PARALLEL: &str = "PARALLEL";
pub(crate) const QUIET: &str = "QUIET";
pub(crate) const SET: &str = "SET";
pub(crate) const SHELL: &str = "SHELL";
Expand Down Expand Up @@ -195,6 +197,12 @@ impl Config {
.takes_value(true)
.help("Use <JUSTFILE> as justfile"),
)
.arg(
Arg::with_name(arg::PARALLEL)
.short("p")
.long("parallel")
.help("run task dependencies & given tasks in parallel")
)
.arg(
Arg::with_name(arg::QUIET)
.short("q")
Expand Down Expand Up @@ -571,6 +579,7 @@ impl Config {
Ok(Self {
check: matches.is_present(arg::CHECK),
dry_run: matches.is_present(arg::DRY_RUN),
parallel: matches.is_present(arg::PARALLEL),
dump_format: Self::dump_format_from_matches(matches)?,
highlight: !matches.is_present(arg::NO_HIGHLIGHT),
shell: matches.value_of(arg::SHELL).map(str::to_owned),
Expand Down Expand Up @@ -628,6 +637,7 @@ mod tests {
args: [$($arg:expr),*],
$(color: $color:expr,)?
$(dry_run: $dry_run:expr,)?
$(parallel: $parallel:expr,)?
$(dump_format: $dump_format:expr,)?
$(highlight: $highlight:expr,)?
$(search_config: $search_config:expr,)?
Expand All @@ -647,6 +657,7 @@ mod tests {
let want = Config {
$(color: $color,)?
$(dry_run: $dry_run,)?
$(parallel: $parallel,)?
$(dump_format: $dump_format,)?
$(highlight: $highlight,)?
$(search_config: $search_config,)?
Expand Down Expand Up @@ -783,6 +794,18 @@ mod tests {
dry_run: true,
}

test! {
name: parallel_long,
args: ["--parallel"],
parallel: true,
}

test! {
name: parallel_short,
args: ["-p"],
parallel: true,
}

error! {
name: dry_run_quiet,
args: ["--dry-run", "--quiet"],
Expand Down

0 comments on commit c21d46a

Please sign in to comment.