mirror of
https://github.com/casey/just.git
synced 2024-11-22 02:09:44 +03:00
Merge cb1a1855cf
into 17350a603e
This commit is contained in:
commit
09ab922644
@ -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,6 +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 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";
|
||||
@ -315,6 +317,13 @@ impl Config {
|
||||
.help("Suppress all output")
|
||||
.conflicts_with(arg::DRY_RUN),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(arg::ALLOW_MISSING)
|
||||
.long("allow-missing")
|
||||
.env("JUST_ALLOW_MISSING")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Suppress error code"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(arg::SET)
|
||||
.long("set")
|
||||
@ -729,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,
|
||||
|
10
src/run.rs
10
src/run.rs
@ -15,9 +15,9 @@ pub fn run(args: impl Iterator<Item = impl Into<OsString> + 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,6 +28,12 @@ pub fn run(args: impl Iterator<Item = impl Into<OsString> + Clone>) -> Result<()
|
||||
config.subcommand.execute(&config, &loader)
|
||||
})
|
||||
.map_err(|error| {
|
||||
if allow_missing {
|
||||
if let Error::UnknownRecipe { .. } = error {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if !verbosity.quiet() && error.print_message() {
|
||||
eprintln!("{}", error.color_display(color.stderr()));
|
||||
}
|
||||
|
33
tests/allow_missing.rs
Normal file
33
tests/allow_missing.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn fail_on_unknown_recipe() {
|
||||
Test::new()
|
||||
.arg("execute")
|
||||
.justfile(
|
||||
"
|
||||
build:
|
||||
echo \"Building...\"
|
||||
",
|
||||
)
|
||||
.stderr("error: Justfile does not contain recipe `execute`.\n")
|
||||
.stdout("")
|
||||
.status(1)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_unknown_recipe() {
|
||||
Test::new()
|
||||
.args(["--allow-missing", "execute"])
|
||||
.justfile(
|
||||
"
|
||||
build:
|
||||
echo \"Building...\"
|
||||
",
|
||||
)
|
||||
.stderr("")
|
||||
.stdout("")
|
||||
.status(0)
|
||||
.run();
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user