diff options
author | Brenley Dueck <brenleydueck@gmail.com> | 2022-09-28 11:47:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 18:47:48 +0200 |
commit | 23125b275f282f96a6316d11f97e5603dab0d009 (patch) | |
tree | 374ef90c365657aca64c58ecb007ce510472ab24 /cli/args/flags.rs | |
parent | 9c861ec4301397456e249923c881d9d3b56651f4 (diff) |
feat(lint): add --compact flag for terse output (#15926)
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 46fa8c552..a4eca942f 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -154,6 +154,7 @@ pub struct LintFlags { pub maybe_rules_include: Option<Vec<String>>, pub maybe_rules_exclude: Option<Vec<String>>, pub json: bool, + pub compact: bool, } #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] @@ -1402,6 +1403,13 @@ Ignore linting a file by adding an ignore comment at the top of the file: .takes_value(false), ) .arg( + Arg::new("compact") + .long("compact") + .help("Output lint result in compact format") + .takes_value(false) + .conflicts_with("json"), + ) + .arg( Arg::new("files") .takes_value(true) .multiple_values(true) @@ -2584,6 +2592,7 @@ fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) { .map(|f| f.map(String::from).collect()); let json = matches.is_present("json"); + let compact = matches.is_present("compact"); flags.subcommand = DenoSubcommand::Lint(LintFlags { files, rules, @@ -2592,6 +2601,7 @@ fn lint_parse(flags: &mut Flags, matches: &clap::ArgMatches) { maybe_rules_exclude, ignore, json, + compact, }); } @@ -3686,6 +3696,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: false, + compact: false, ignore: vec![], }), ..Flags::default() @@ -3712,6 +3723,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: false, + compact: false, ignore: vec![], }), watch: Some(vec![]), @@ -3740,6 +3752,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: false, + compact: false, ignore: vec![], }), watch: Some(vec![]), @@ -3760,6 +3773,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: false, + compact: false, ignore: vec![ PathBuf::from("script_1.ts"), PathBuf::from("script_2.ts") @@ -3780,6 +3794,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: false, + compact: false, ignore: vec![], }), ..Flags::default() @@ -3803,6 +3818,7 @@ mod tests { maybe_rules_include: Some(svec!["ban-untagged-todo", "no-undef"]), maybe_rules_exclude: Some(svec!["no-const-assign"]), json: false, + compact: false, ignore: vec![], }), ..Flags::default() @@ -3820,6 +3836,7 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: true, + compact: false, ignore: vec![], }), ..Flags::default() @@ -3844,6 +3861,33 @@ mod tests { maybe_rules_include: None, maybe_rules_exclude: None, json: true, + compact: false, + ignore: vec![], + }), + config_flag: ConfigFlag::Path("Deno.jsonc".to_string()), + ..Flags::default() + } + ); + + let r = flags_from_vec(svec![ + "deno", + "lint", + "--config", + "Deno.jsonc", + "--compact", + "script_1.ts" + ]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Lint(LintFlags { + files: vec![PathBuf::from("script_1.ts")], + rules: false, + maybe_rules_tags: None, + maybe_rules_include: None, + maybe_rules_exclude: None, + json: false, + compact: true, ignore: vec![], }), config_flag: ConfigFlag::Path("Deno.jsonc".to_string()), |