diff --git a/src/config.rs b/src/config.rs index 23a04ed79a..11023fc882 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,6 +24,7 @@ pub(crate) struct Config { pub(crate) list_submodules: bool, pub(crate) load_dotenv: bool, pub(crate) no_aliases: bool, + pub(crate) allow_missing: bool, pub(crate) no_dependencies: bool, pub(crate) one: bool, pub(crate) search_config: SearchConfig, @@ -103,7 +104,7 @@ mod arg { pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT"; pub(crate) const ONE: &str = "ONE"; pub(crate) const QUIET: &str = "QUIET"; - pub(crate) const IF_PRESENT: &str = "IF-PRESENT"; + pub(crate) const ALLOW_MISSING: &str = "ALLOW-MISSING"; pub(crate) const SET: &str = "SET"; pub(crate) const SHELL: &str = "SHELL"; pub(crate) const SHELL_ARG: &str = "SHELL-ARG"; @@ -317,9 +318,9 @@ impl Config { .conflicts_with(arg::DRY_RUN), ) .arg( - Arg::new(arg::IF_PRESENT) - .long("if-present") - .env("JUST_IF_PRESENT") + Arg::new(arg::ALLOW_MISSING) + .long("allow-missing") + .env("JUST_ALLOW_MISSING") .action(ArgAction::SetTrue) .help("Suppress error code"), ) @@ -737,6 +738,7 @@ impl Config { list_submodules: matches.get_flag(arg::LIST_SUBMODULES), load_dotenv: !matches.get_flag(arg::NO_DOTENV), no_aliases: matches.get_flag(arg::NO_ALIASES), + allow_missing: matches.get_flag(arg::ALLOW_MISSING), no_dependencies: matches.get_flag(arg::NO_DEPS), one: matches.get_flag(arg::ONE), search_config, @@ -759,8 +761,6 @@ impl Config { unstable, verbosity: if matches.get_flag(arg::QUIET) { Verbosity::Quiet - } else if matches.get_flag(arg::IF_PRESENT) { - Verbosity::RecipeQuiet } else { Verbosity::from_flag_occurrences(matches.get_count(arg::VERBOSE)) }, diff --git a/src/run.rs b/src/run.rs index 2f3d5a8c8b..00b809d13f 100644 --- a/src/run.rs +++ b/src/run.rs @@ -15,9 +15,9 @@ pub fn run(args: impl Iterator + Clone>) -> Result<() let config = Config::from_matches(&matches).map_err(Error::from); - let (color, verbosity) = config + let (color, verbosity, allow_missing) = config .as_ref() - .map(|config| (config.color, config.verbosity)) + .map(|config| (config.color, config.verbosity, config.allow_missing)) .unwrap_or_default(); let loader = Loader::new(); @@ -28,11 +28,10 @@ pub fn run(args: impl Iterator + Clone>) -> Result<() config.subcommand.execute(&config, &loader) }) .map_err(|error| { - if verbosity.recipe_quiet() { - match error { - Error::UnknownRecipe { .. } => return 0, - _ => {} - }; + if allow_missing { + if let Error::UnknownRecipe { .. } = error { + return 0; + } } if !verbosity.quiet() && error.print_message() { diff --git a/src/verbosity.rs b/src/verbosity.rs index 20dc8a65eb..f3ba3e4585 100644 --- a/src/verbosity.rs +++ b/src/verbosity.rs @@ -1,7 +1,6 @@ #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] pub(crate) enum Verbosity { Quiet, - RecipeQuiet, Taciturn, Loquacious, Grandiloquent, @@ -20,10 +19,6 @@ impl Verbosity { self == Self::Quiet } - pub(crate) fn recipe_quiet(self) -> bool { - self == Self::RecipeQuiet - } - pub(crate) fn loud(self) -> bool { !self.quiet() } diff --git a/tests/if_present.rs b/tests/allow_missing.rs similarity index 86% rename from tests/if_present.rs rename to tests/allow_missing.rs index 32054a29da..2d74f27a78 100644 --- a/tests/if_present.rs +++ b/tests/allow_missing.rs @@ -1,7 +1,7 @@ use super::*; #[test] -fn without_if_present() { +fn fail_on_unknown_recipe() { Test::new() .arg("execute") .justfile( @@ -19,7 +19,7 @@ fn without_if_present() { #[test] fn ignore_unknown_recipe() { Test::new() - .args(["--if-present", "execute"]) + .args(["--allow-missing", "execute"]) .justfile( " build: diff --git a/tests/lib.rs b/tests/lib.rs index 2576e78289..fb0cf66145 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -33,6 +33,7 @@ mod test; mod allow_duplicate_recipes; mod allow_duplicate_variables; +mod allow_missing; mod assert_stdout; mod assert_success; mod assertions; @@ -64,7 +65,6 @@ mod functions; #[cfg(unix)] mod global; mod groups; -mod if_present; mod ignore_comments; mod imports; mod init;