Add --no-deps
to skip running recipe dependencies (#1819)
This commit is contained in:
parent
541e78104c
commit
b66cce0f58
@ -20,7 +20,7 @@ _just() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
just)
|
just)
|
||||||
opts=" -n -q -u -v -e -l -h -V -f -d -c -s --check --yes --dry-run --highlight --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path <ARGUMENTS>... "
|
opts=" -n -q -u -v -e -l -h -V -f -d -c -s --check --yes --dry-run --highlight --no-deps --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path <ARGUMENTS>... "
|
||||||
if [[ ${cur} == -* ]] ; then
|
if [[ ${cur} == -* ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
|
@ -39,6 +39,7 @@ edit:completion:arg-completer[just] = [@words]{
|
|||||||
cand -n 'Print what just would do without doing it'
|
cand -n 'Print what just would do without doing it'
|
||||||
cand --dry-run 'Print what just would do without doing it'
|
cand --dry-run 'Print what just would do without doing it'
|
||||||
cand --highlight 'Highlight echoed recipe lines in bold'
|
cand --highlight 'Highlight echoed recipe lines in bold'
|
||||||
|
cand --no-deps 'Don''t run recipe dependencies'
|
||||||
cand --no-dotenv 'Don''t load `.env` file'
|
cand --no-dotenv 'Don''t load `.env` file'
|
||||||
cand --no-highlight 'Don''t highlight echoed recipe lines in bold'
|
cand --no-highlight 'Don''t highlight echoed recipe lines in bold'
|
||||||
cand -q 'Suppress all output'
|
cand -q 'Suppress all output'
|
||||||
|
@ -55,6 +55,7 @@ complete -c just -n "__fish_use_subcommand" -l check -d 'Run `--fmt` in \'check\
|
|||||||
complete -c just -n "__fish_use_subcommand" -l yes -d 'Automatically confirm all recipes.'
|
complete -c just -n "__fish_use_subcommand" -l yes -d 'Automatically confirm all recipes.'
|
||||||
complete -c just -n "__fish_use_subcommand" -s n -l dry-run -d 'Print what just would do without doing it'
|
complete -c just -n "__fish_use_subcommand" -s n -l dry-run -d 'Print what just would do without doing it'
|
||||||
complete -c just -n "__fish_use_subcommand" -l highlight -d 'Highlight echoed recipe lines in bold'
|
complete -c just -n "__fish_use_subcommand" -l highlight -d 'Highlight echoed recipe lines in bold'
|
||||||
|
complete -c just -n "__fish_use_subcommand" -l no-deps -d 'Don\'t run recipe dependencies'
|
||||||
complete -c just -n "__fish_use_subcommand" -l no-dotenv -d 'Don\'t load `.env` file'
|
complete -c just -n "__fish_use_subcommand" -l no-dotenv -d 'Don\'t load `.env` file'
|
||||||
complete -c just -n "__fish_use_subcommand" -l no-highlight -d 'Don\'t highlight echoed recipe lines in bold'
|
complete -c just -n "__fish_use_subcommand" -l no-highlight -d 'Don\'t highlight echoed recipe lines in bold'
|
||||||
complete -c just -n "__fish_use_subcommand" -s q -l quiet -d 'Suppress all output'
|
complete -c just -n "__fish_use_subcommand" -s q -l quiet -d 'Suppress all output'
|
||||||
|
@ -44,6 +44,7 @@ Register-ArgumentCompleter -Native -CommandName 'just' -ScriptBlock {
|
|||||||
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
||||||
[CompletionResult]::new('--dry-run', 'dry-run', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
[CompletionResult]::new('--dry-run', 'dry-run', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
||||||
[CompletionResult]::new('--highlight', 'highlight', [CompletionResultType]::ParameterName, 'Highlight echoed recipe lines in bold')
|
[CompletionResult]::new('--highlight', 'highlight', [CompletionResultType]::ParameterName, 'Highlight echoed recipe lines in bold')
|
||||||
|
[CompletionResult]::new('--no-deps', 'no-deps', [CompletionResultType]::ParameterName, 'Don''t run recipe dependencies')
|
||||||
[CompletionResult]::new('--no-dotenv', 'no-dotenv', [CompletionResultType]::ParameterName, 'Don''t load `.env` file')
|
[CompletionResult]::new('--no-dotenv', 'no-dotenv', [CompletionResultType]::ParameterName, 'Don''t load `.env` file')
|
||||||
[CompletionResult]::new('--no-highlight', 'no-highlight', [CompletionResultType]::ParameterName, 'Don''t highlight echoed recipe lines in bold')
|
[CompletionResult]::new('--no-highlight', 'no-highlight', [CompletionResultType]::ParameterName, 'Don''t highlight echoed recipe lines in bold')
|
||||||
[CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Suppress all output')
|
[CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Suppress all output')
|
||||||
|
@ -40,6 +40,7 @@ _just() {
|
|||||||
'(-q --quiet)-n[Print what just would do without doing it]' \
|
'(-q --quiet)-n[Print what just would do without doing it]' \
|
||||||
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
|
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
|
||||||
'--highlight[Highlight echoed recipe lines in bold]' \
|
'--highlight[Highlight echoed recipe lines in bold]' \
|
||||||
|
'--no-deps[Don'\''t run recipe dependencies]' \
|
||||||
'--no-dotenv[Don'\''t load `.env` file]' \
|
'--no-dotenv[Don'\''t load `.env` file]' \
|
||||||
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
|
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
|
||||||
'(-n --dry-run)-q[Suppress all output]' \
|
'(-n --dry-run)-q[Suppress all output]' \
|
||||||
|
@ -31,6 +31,7 @@ pub(crate) struct Config {
|
|||||||
pub(crate) list_heading: String,
|
pub(crate) list_heading: String,
|
||||||
pub(crate) list_prefix: String,
|
pub(crate) list_prefix: String,
|
||||||
pub(crate) load_dotenv: bool,
|
pub(crate) load_dotenv: bool,
|
||||||
|
pub(crate) no_dependencies: bool,
|
||||||
pub(crate) search_config: SearchConfig,
|
pub(crate) search_config: SearchConfig,
|
||||||
pub(crate) shell: Option<String>,
|
pub(crate) shell: Option<String>,
|
||||||
pub(crate) shell_args: Option<Vec<String>>,
|
pub(crate) shell_args: Option<Vec<String>>,
|
||||||
@ -102,6 +103,7 @@ mod arg {
|
|||||||
pub(crate) const JUSTFILE: &str = "JUSTFILE";
|
pub(crate) const JUSTFILE: &str = "JUSTFILE";
|
||||||
pub(crate) const LIST_HEADING: &str = "LIST-HEADING";
|
pub(crate) const LIST_HEADING: &str = "LIST-HEADING";
|
||||||
pub(crate) const LIST_PREFIX: &str = "LIST-PREFIX";
|
pub(crate) const LIST_PREFIX: &str = "LIST-PREFIX";
|
||||||
|
pub(crate) const NO_DEPS: &str = "NO-DEPS";
|
||||||
pub(crate) const NO_DOTENV: &str = "NO-DOTENV";
|
pub(crate) const NO_DOTENV: &str = "NO-DOTENV";
|
||||||
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
|
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
|
||||||
pub(crate) const QUIET: &str = "QUIET";
|
pub(crate) const QUIET: &str = "QUIET";
|
||||||
@ -213,6 +215,12 @@ impl Config {
|
|||||||
.value_name("TEXT")
|
.value_name("TEXT")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
|
.arg (
|
||||||
|
Arg::with_name(arg::NO_DEPS)
|
||||||
|
.long("no-deps")
|
||||||
|
.alias("no-dependencies")
|
||||||
|
.help("Don't run recipe dependencies")
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(arg::NO_DOTENV)
|
Arg::with_name(arg::NO_DOTENV)
|
||||||
.long("no-dotenv")
|
.long("no-dotenv")
|
||||||
@ -650,6 +658,7 @@ impl Config {
|
|||||||
.unwrap_or(" ")
|
.unwrap_or(" ")
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
load_dotenv: !matches.is_present(arg::NO_DOTENV),
|
load_dotenv: !matches.is_present(arg::NO_DOTENV),
|
||||||
|
no_dependencies: matches.is_present(arg::NO_DEPS),
|
||||||
search_config,
|
search_config,
|
||||||
shell: matches.value_of(arg::SHELL).map(str::to_owned),
|
shell: matches.value_of(arg::SHELL).map(str::to_owned),
|
||||||
shell_args,
|
shell_args,
|
||||||
@ -695,6 +704,7 @@ mod tests {
|
|||||||
$(dry_run: $dry_run:expr,)?
|
$(dry_run: $dry_run:expr,)?
|
||||||
$(dump_format: $dump_format:expr,)?
|
$(dump_format: $dump_format:expr,)?
|
||||||
$(highlight: $highlight:expr,)?
|
$(highlight: $highlight:expr,)?
|
||||||
|
$(no_dependencies: $no_dependencies:expr,)?
|
||||||
$(search_config: $search_config:expr,)?
|
$(search_config: $search_config:expr,)?
|
||||||
$(shell: $shell:expr,)?
|
$(shell: $shell:expr,)?
|
||||||
$(shell_args: $shell_args:expr,)?
|
$(shell_args: $shell_args:expr,)?
|
||||||
@ -714,6 +724,7 @@ mod tests {
|
|||||||
$(dry_run: $dry_run,)?
|
$(dry_run: $dry_run,)?
|
||||||
$(dump_format: $dump_format,)?
|
$(dump_format: $dump_format,)?
|
||||||
$(highlight: $highlight,)?
|
$(highlight: $highlight,)?
|
||||||
|
$(no_dependencies: $no_dependencies,)?
|
||||||
$(search_config: $search_config,)?
|
$(search_config: $search_config,)?
|
||||||
$(shell: $shell,)?
|
$(shell: $shell,)?
|
||||||
$(shell_args: $shell_args,)?
|
$(shell_args: $shell_args,)?
|
||||||
@ -889,6 +900,18 @@ mod tests {
|
|||||||
highlight: false,
|
highlight: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test! {
|
||||||
|
name: no_deps,
|
||||||
|
args: ["--no-deps"],
|
||||||
|
no_dependencies: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
test! {
|
||||||
|
name: no_dependencies,
|
||||||
|
args: ["--no-dependencies"],
|
||||||
|
no_dependencies: true,
|
||||||
|
}
|
||||||
|
|
||||||
test! {
|
test! {
|
||||||
name: unsorted_default,
|
name: unsorted_default,
|
||||||
args: [],
|
args: [],
|
||||||
|
@ -281,17 +281,17 @@ impl<'src> Justfile<'src> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Self::run_recipe(
|
Self::run_recipe(
|
||||||
&context,
|
|
||||||
invocation.recipe,
|
|
||||||
&invocation
|
&invocation
|
||||||
.arguments
|
.arguments
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
.map(str::to_string)
|
.map(str::to_string)
|
||||||
.collect::<Vec<String>>(),
|
.collect::<Vec<String>>(),
|
||||||
|
&context,
|
||||||
&dotenv,
|
&dotenv,
|
||||||
search,
|
|
||||||
&mut ran,
|
&mut ran,
|
||||||
|
invocation.recipe,
|
||||||
|
search,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,12 +402,12 @@ impl<'src> Justfile<'src> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_recipe(
|
fn run_recipe(
|
||||||
context: &RecipeContext<'src, '_>,
|
|
||||||
recipe: &Recipe<'src>,
|
|
||||||
arguments: &[String],
|
arguments: &[String],
|
||||||
|
context: &RecipeContext<'src, '_>,
|
||||||
dotenv: &BTreeMap<String, String>,
|
dotenv: &BTreeMap<String, String>,
|
||||||
search: &Search,
|
|
||||||
ran: &mut Ran<'src>,
|
ran: &mut Ran<'src>,
|
||||||
|
recipe: &Recipe<'src>,
|
||||||
|
search: &Search,
|
||||||
) -> RunResult<'src> {
|
) -> RunResult<'src> {
|
||||||
if ran.has_run(&recipe.namepath, arguments) {
|
if ran.has_run(&recipe.namepath, arguments) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -434,18 +434,20 @@ impl<'src> Justfile<'src> {
|
|||||||
let mut evaluator =
|
let mut evaluator =
|
||||||
Evaluator::recipe_evaluator(context.config, dotenv, &scope, context.settings, search);
|
Evaluator::recipe_evaluator(context.config, dotenv, &scope, context.settings, search);
|
||||||
|
|
||||||
for Dependency { recipe, arguments } in recipe.dependencies.iter().take(recipe.priors) {
|
if !context.config.no_dependencies {
|
||||||
let arguments = arguments
|
for Dependency { recipe, arguments } in recipe.dependencies.iter().take(recipe.priors) {
|
||||||
.iter()
|
let arguments = arguments
|
||||||
.map(|argument| evaluator.evaluate_expression(argument))
|
.iter()
|
||||||
.collect::<RunResult<Vec<String>>>()?;
|
.map(|argument| evaluator.evaluate_expression(argument))
|
||||||
|
.collect::<RunResult<Vec<String>>>()?;
|
||||||
|
|
||||||
Self::run_recipe(context, recipe, &arguments, dotenv, search, ran)?;
|
Self::run_recipe(&arguments, context, dotenv, ran, recipe, search)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recipe.run(context, dotenv, scope.child(), search, &positional)?;
|
recipe.run(context, dotenv, scope.child(), search, &positional)?;
|
||||||
|
|
||||||
{
|
if !context.config.no_dependencies {
|
||||||
let mut ran = Ran::default();
|
let mut ran = Ran::default();
|
||||||
|
|
||||||
for Dependency { recipe, arguments } in recipe.dependencies.iter().skip(recipe.priors) {
|
for Dependency { recipe, arguments } in recipe.dependencies.iter().skip(recipe.priors) {
|
||||||
@ -455,7 +457,7 @@ impl<'src> Justfile<'src> {
|
|||||||
evaluated.push(evaluator.evaluate_expression(argument)?);
|
evaluated.push(evaluator.evaluate_expression(argument)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::run_recipe(context, recipe, &evaluated, dotenv, search, &mut ran)?;
|
Self::run_recipe(&evaluated, context, dotenv, &mut ran, recipe, search)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ mod modules;
|
|||||||
mod multibyte_char;
|
mod multibyte_char;
|
||||||
mod newline_escape;
|
mod newline_escape;
|
||||||
mod no_cd;
|
mod no_cd;
|
||||||
|
mod no_dependencies;
|
||||||
mod no_exit_message;
|
mod no_exit_message;
|
||||||
mod os_attributes;
|
mod os_attributes;
|
||||||
mod parser;
|
mod parser;
|
||||||
|
49
tests/no_dependencies.rs
Normal file
49
tests/no_dependencies.rs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skip_normal_dependency() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
a:
|
||||||
|
@echo 'a'
|
||||||
|
b: a
|
||||||
|
@echo 'b'
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.args(["--no-deps", "b"])
|
||||||
|
.stdout("b\n")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skip_prior_dependency() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
a:
|
||||||
|
@echo 'a'
|
||||||
|
b: && a
|
||||||
|
@echo 'b'
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.args(["--no-deps", "b"])
|
||||||
|
.stdout("b\n")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skip_dependency_multi() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
a:
|
||||||
|
@echo 'a'
|
||||||
|
b: && a
|
||||||
|
@echo 'b'
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.args(["--no-deps", "b", "a"])
|
||||||
|
.stdout("b\na\n")
|
||||||
|
.run();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user