fix(task): remove --no-config as task subcommand argument (#14983)

This commit is contained in:
Geert-Jan Zwiers 2022-06-28 21:47:51 +02:00 committed by GitHub
parent 0f6a5c5fc2
commit 5b7bcefa11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1055,7 +1055,8 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
// deno-fmt-ignore-file",
)
.args(config_args())
.arg(config_arg())
.arg(no_config_arg())
.arg(
Arg::new("check")
.long("check")
@ -1165,7 +1166,8 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
)
// TODO(lucacasonato): remove for 2.0
.arg(no_check_arg().hide(true))
.args(config_args())
.arg(no_config_arg())
.arg(config_arg())
.arg(import_map_arg())
.arg(
Arg::new("json")
@ -1344,7 +1346,8 @@ Ignore linting a file by adding an ignore comment at the top of the file:
.conflicts_with("rules")
.help("Exclude lint rules"),
)
.args(config_args())
.arg(no_config_arg())
.arg(config_arg())
.arg(
Arg::new("ignore")
.long("ignore")
@ -1435,7 +1438,7 @@ Specifying the filename '-' to read the file from stdin.
fn task_subcommand<'a>() -> Command<'a> {
Command::new("task")
.trailing_var_arg(true)
.args(config_args())
.arg(config_arg())
.arg(
Arg::new("cwd")
.long("cwd")
@ -1687,7 +1690,8 @@ Remote modules and multiple modules may also be specified:
)
.takes_value(false),
)
.args(config_args())
.arg(no_config_arg())
.arg(config_arg())
.arg(import_map_arg())
.arg(lock_arg())
.arg(reload_arg())
@ -1698,7 +1702,8 @@ fn compile_args(app: Command) -> Command {
app
.arg(import_map_arg())
.arg(no_remote_arg())
.args(config_args())
.arg(no_config_arg())
.arg(config_arg())
.arg(no_check_arg())
.arg(check_arg())
.arg(reload_arg())
@ -1711,7 +1716,8 @@ fn compile_args_without_check_args(app: Command) -> Command {
app
.arg(import_map_arg())
.arg(no_remote_arg())
.args(config_args())
.arg(config_arg())
.arg(no_config_arg())
.arg(reload_arg())
.arg(lock_arg())
.arg(lock_write_arg())
@ -2095,22 +2101,22 @@ static CONFIG_HELP: Lazy<String> = Lazy::new(|| {
)
});
fn config_args<'a>() -> [Arg<'a>; 2] {
[
Arg::new("config")
.short('c')
.long("config")
.value_name("FILE")
.help("Specify the configuration file")
.long_help(CONFIG_HELP.as_str())
.takes_value(true)
.value_hint(ValueHint::FilePath)
.conflicts_with("no-config"),
Arg::new("no-config")
.long("no-config")
.help("Disable automatic loading of the configuration file.")
.conflicts_with("config"),
]
fn config_arg<'a>() -> Arg<'a> {
Arg::new("config")
.short('c')
.long("config")
.value_name("FILE")
.help("Specify the configuration file")
.long_help(CONFIG_HELP.as_str())
.takes_value(true)
.value_hint(ValueHint::FilePath)
}
fn no_config_arg<'a>() -> Arg<'a> {
Arg::new("no-config")
.long("no-config")
.help("Disable automatic loading of the configuration file.")
.conflicts_with("config")
}
fn no_remote_arg<'a>() -> Arg<'a> {
@ -2551,7 +2557,11 @@ fn task_parse(
matches: &clap::ArgMatches,
raw_args: &[String],
) {
config_args_parse(flags, matches);
flags.config_flag = if let Some(config) = matches.value_of("config") {
ConfigFlag::Path(config.to_string())
} else {
ConfigFlag::Discover
};
let mut task_flags = TaskFlags {
cwd: None,
@ -5786,6 +5796,12 @@ mod tests {
);
}
#[test]
fn task_subcommand_noconfig_invalid() {
let r = flags_from_vec(svec!["deno", "task", "--no-config"]);
assert_eq!(r.unwrap_err().kind(), clap::ErrorKind::UnknownArgument);
}
#[test]
fn bench_with_flags() {
let r = flags_from_vec(svec![