diff options
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 6affa9f08..e283abc24 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -200,6 +200,7 @@ pub struct FmtFlags { pub prose_wrap: Option<String>, pub no_semicolons: Option<bool>, pub watch: Option<WatchFlags>, + pub unstable_yaml: bool, } impl FmtFlags { @@ -2074,6 +2075,13 @@ Ignore formatting a file by adding an ignore comment at the top of the file: "Don't use semicolons except where necessary. Defaults to false.", ), ) + .arg( + Arg::new("unstable-yaml") + .long("unstable-yaml") + .help("Enable formatting YAML files.") + .value_parser(FalseyValueParser::new()) + .action(ArgAction::SetTrue), + ) }) } @@ -4088,6 +4096,7 @@ fn fmt_parse(flags: &mut Flags, matches: &mut ArgMatches) { let single_quote = matches.remove_one::<bool>("single-quote"); let prose_wrap = matches.remove_one::<String>("prose-wrap"); let no_semicolons = matches.remove_one::<bool>("no-semicolons"); + let unstable_yaml = matches.get_flag("unstable-yaml"); flags.subcommand = DenoSubcommand::Fmt(FmtFlags { check: matches.get_flag("check"), @@ -4099,6 +4108,7 @@ fn fmt_parse(flags: &mut Flags, matches: &mut ArgMatches) { prose_wrap, no_semicolons, watch: watch_arg_parse(matches), + unstable_yaml, }); } @@ -5781,6 +5791,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), @@ -5804,6 +5815,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), @@ -5827,6 +5839,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), @@ -5850,6 +5863,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Some(Default::default()), }), ext: Some("ts".to_string()), @@ -5857,8 +5871,13 @@ mod tests { } ); - let r = - flags_from_vec(svec!["deno", "fmt", "--watch", "--no-clear-screen"]); + let r = flags_from_vec(svec![ + "deno", + "fmt", + "--watch", + "--no-clear-screen", + "--unstable-yaml" + ]); assert_eq!( r.unwrap(), Flags { @@ -5874,6 +5893,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: true, watch: Some(WatchFlags { hmr: false, no_clear_screen: true, @@ -5908,6 +5928,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Some(Default::default()), }), ext: Some("ts".to_string()), @@ -5931,6 +5952,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), @@ -5962,6 +5984,7 @@ mod tests { single_quote: None, prose_wrap: None, no_semicolons: None, + unstable_yaml: false, watch: Some(Default::default()), }), config_flag: ConfigFlag::Path("deno.jsonc".to_string()), @@ -5998,6 +6021,7 @@ mod tests { single_quote: Some(true), prose_wrap: Some("never".to_string()), no_semicolons: Some(true), + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), @@ -6028,6 +6052,7 @@ mod tests { single_quote: Some(false), prose_wrap: None, no_semicolons: Some(false), + unstable_yaml: false, watch: Default::default(), }), ext: Some("ts".to_string()), |