summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/flags.rs57
-rw-r--r--cli/args/mod.rs12
2 files changed, 42 insertions, 27 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 46560b9ba..3810d77a3 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -405,6 +405,17 @@ pub enum CaData {
Bytes(Vec<u8>),
}
+#[derive(
+ Clone, Default, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize,
+)]
+pub struct UnstableConfig {
+ pub legacy_flag_enabled: bool, // --unstable
+ pub bare_node_builtins: bool, // --unstable-bare-node-builts
+ pub byonm: bool,
+ pub sloppy_imports: bool,
+ pub features: Vec<String>, // --unstabe-kv --unstable-cron
+}
+
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct Flags {
/// Vector of CLI arguments - these are user script arguments, all Deno
@@ -460,12 +471,7 @@ pub struct Flags {
pub reload: bool,
pub seed: Option<u64>,
pub strace_ops: Option<Vec<String>>,
- pub unstable: bool,
- pub unstable_bare_node_builtins: bool,
- pub unstable_byonm: bool,
- pub unstable_sloppy_imports: bool,
- pub unstable_workspaces: bool,
- pub unstable_features: Vec<String>,
+ pub unstable_config: UnstableConfig,
pub unsafely_ignore_certificate_errors: Option<Vec<String>>,
pub v8_flags: Vec<String>,
}
@@ -865,19 +871,20 @@ pub fn flags_from_vec(args: Vec<String>) -> clap::error::Result<Flags> {
let mut flags = Flags::default();
if matches.get_flag("unstable") {
- flags.unstable = true;
+ flags.unstable_config.legacy_flag_enabled = true;
}
for (name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS {
if matches.get_flag(&format!("unstable-{}", name)) {
- flags.unstable_features.push(name.to_string());
+ flags.unstable_config.features.push(name.to_string());
}
}
- flags.unstable_bare_node_builtins =
+ flags.unstable_config.bare_node_builtins =
matches.get_flag("unstable-bare-node-builtins");
- flags.unstable_byonm = matches.get_flag("unstable-byonm");
- flags.unstable_sloppy_imports = matches.get_flag("unstable-sloppy-imports");
+ flags.unstable_config.byonm = matches.get_flag("unstable-byonm");
+ flags.unstable_config.sloppy_imports =
+ matches.get_flag("unstable-sloppy-imports");
if matches.get_flag("quiet") {
flags.log_level = Some(Level::Error);
@@ -4199,7 +4206,10 @@ mod tests {
subcommand: DenoSubcommand::Run(RunFlags::new_default(
"script.ts".to_string()
)),
- unstable: true,
+ unstable_config: UnstableConfig {
+ legacy_flag_enabled: true,
+ ..Default::default()
+ },
log_level: Some(Level::Error),
..Flags::default()
}
@@ -7054,7 +7064,10 @@ mod tests {
reporter: Default::default(),
junit_path: None,
}),
- unstable: true,
+ unstable_config: UnstableConfig {
+ legacy_flag_enabled: true,
+ ..Default::default()
+ },
no_prompt: true,
no_npm: true,
no_remote: true,
@@ -8189,7 +8202,10 @@ mod tests {
cwd: None,
task: Some("build".to_string()),
}),
- unstable: true,
+ unstable_config: UnstableConfig {
+ legacy_flag_enabled: true,
+ ..Default::default()
+ },
log_level: Some(log::Level::Error),
..Flags::default()
}
@@ -8286,7 +8302,10 @@ mod tests {
},
watch: Default::default(),
}),
- unstable: true,
+ unstable_config: UnstableConfig {
+ legacy_flag_enabled: true,
+ ..Default::default()
+ },
no_npm: true,
no_remote: true,
type_check_mode: TypeCheckMode::Local,
@@ -8430,7 +8449,7 @@ mod tests {
#[test]
fn jupyter() {
- let r = flags_from_vec(svec!["deno", "jupyter", "--unstable"]);
+ let r = flags_from_vec(svec!["deno", "jupyter"]);
assert_eq!(
r.unwrap(),
Flags {
@@ -8439,12 +8458,11 @@ mod tests {
kernel: false,
conn_file: None,
}),
- unstable: true,
..Flags::default()
}
);
- let r = flags_from_vec(svec!["deno", "jupyter", "--unstable", "--install"]);
+ let r = flags_from_vec(svec!["deno", "jupyter", "--install"]);
assert_eq!(
r.unwrap(),
Flags {
@@ -8453,7 +8471,6 @@ mod tests {
kernel: false,
conn_file: None,
}),
- unstable: true,
..Flags::default()
}
);
@@ -8461,7 +8478,6 @@ mod tests {
let r = flags_from_vec(svec![
"deno",
"jupyter",
- "--unstable",
"--kernel",
"--conn",
"path/to/conn/file"
@@ -8474,7 +8490,6 @@ mod tests {
kernel: true,
conn_file: Some(PathBuf::from("path/to/conn/file")),
}),
- unstable: true,
..Flags::default()
}
);
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 1fdd2f503..c6bc712f8 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -1409,12 +1409,12 @@ impl CliOptions {
&self.flags.unsafely_ignore_certificate_errors
}
- pub fn unstable(&self) -> bool {
- self.flags.unstable
+ pub fn legacy_unstable_flag(&self) -> bool {
+ self.flags.unstable_config.legacy_flag_enabled
}
pub fn unstable_bare_node_builtins(&self) -> bool {
- self.flags.unstable_bare_node_builtins
+ self.flags.unstable_config.bare_node_builtins
|| self
.maybe_config_file()
.as_ref()
@@ -1423,7 +1423,7 @@ impl CliOptions {
}
pub fn unstable_byonm(&self) -> bool {
- self.flags.unstable_byonm
+ self.flags.unstable_config.byonm
|| NPM_PROCESS_STATE
.as_ref()
.map(|s| matches!(s.kind, NpmProcessStateKind::Byonm))
@@ -1436,7 +1436,7 @@ impl CliOptions {
}
pub fn unstable_sloppy_imports(&self) -> bool {
- self.flags.unstable_sloppy_imports
+ self.flags.unstable_config.sloppy_imports
|| self
.maybe_config_file()
.as_ref()
@@ -1451,7 +1451,7 @@ impl CliOptions {
.map(|c| c.json.unstable.clone())
.unwrap_or_default();
- from_config_file.extend_from_slice(&self.flags.unstable_features);
+ from_config_file.extend_from_slice(&self.flags.unstable_config.features);
from_config_file
}