summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-08-02 15:52:48 +0200
committerGitHub <noreply@github.com>2024-08-02 13:52:48 +0000
commit0da81205d57e947e82aa02206f8ba6822c624ebc (patch)
tree4472cc6281aca813adc3c2a06321701ea3c3008f /cli/args/flags.rs
parent2aad92c30b327b9db352e8a2c024671205eed9f6 (diff)
feat(unstable/fmt): move yaml formatting behind unstable flag (#24848)
This moves YAML formatting behind an unstable flag for Deno 1.46. This will make it opt-in to start and then we can remove the flag to make it on by default in version of Deno after that. This can be specified by doing `deno fmt --unstable-yaml` or by specifying the following in a deno.json file: ```json { "unstable": ["fmt-yaml"] } ```
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs29
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()),