summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
authorGeert-Jan Zwiers <geertjanzwiers@protonmail.com>2022-06-28 21:47:51 +0200
committerGitHub <noreply@github.com>2022-06-28 21:47:51 +0200
commit5b7bcefa111b1e4fc1e02bb7fb1c8f152e5fd6aa (patch)
treea7b98ef846d8b89832e564a497216511574534a4 /cli/args/flags.rs
parent0f6a5c5fc24e8dc9125c5c536c8547a86ca87b15 (diff)
fix(task): remove --no-config as task subcommand argument (#14983)
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs64
1 files changed, 40 insertions, 24 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index c61e9ab21..f61ead385 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -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,
@@ -5787,6 +5797,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![
"deno",