Add infrastructure for experimental options (#16028)

Co-authored-by: Bahex <Bahex@users.noreply.github.com>
This commit is contained in:
Piepmatz
2025-07-01 18:36:51 +02:00
committed by GitHub
parent f4136aa3f4
commit a86a0dd16e
19 changed files with 731 additions and 24 deletions

View File

@ -16,9 +16,11 @@ bench = false
workspace = true
[dependencies]
nu-ansi-term = { workspace = true }
nu-cmd-base = { path = "../nu-cmd-base", version = "0.105.2" }
nu-color-config = { path = "../nu-color-config", version = "0.105.2" }
nu-engine = { path = "../nu-engine", version = "0.105.2", default-features = false }
nu-experimental = { path = "../nu-experimental", version = "0.105.2" }
nu-glob = { path = "../nu-glob", version = "0.105.2" }
nu-json = { path = "../nu-json", version = "0.105.2" }
nu-parser = { path = "../nu-parser", version = "0.105.2" }
@ -29,7 +31,6 @@ nu-system = { path = "../nu-system", version = "0.105.2" }
nu-table = { path = "../nu-table", version = "0.105.2" }
nu-term-grid = { path = "../nu-term-grid", version = "0.105.2" }
nu-utils = { path = "../nu-utils", version = "0.105.2", default-features = false }
nu-ansi-term = { workspace = true }
nuon = { path = "../nuon", version = "0.105.2" }
alphanumeric-sort = { workspace = true }

View File

@ -0,0 +1,64 @@
use nu_engine::command_prelude::*;
use nu_experimental::Status;
#[derive(Clone)]
pub struct DebugExperimentalOptions;
impl Command for DebugExperimentalOptions {
fn name(&self) -> &str {
"debug experimental-options"
}
fn signature(&self) -> Signature {
Signature::new(self.name())
.input_output_type(
Type::Nothing,
Type::Table(Box::from([
(String::from("identifier"), Type::String),
(String::from("enabled"), Type::Bool),
(String::from("status"), Type::String),
(String::from("description"), Type::String),
])),
)
.add_help()
.category(Category::Debug)
}
fn description(&self) -> &str {
"Show all experimental options."
}
fn run(
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::Value(
Value::list(
nu_experimental::ALL
.iter()
.map(|option| {
Value::record(
nu_protocol::record! {
"identifier" => Value::string(option.identifier(), call.head),
"enabled" => Value::bool(option.get(), call.head),
"status" => Value::string(match option.status() {
Status::OptIn => "opt-in",
Status::OptOut => "opt-out",
Status::DeprecatedDiscard => "deprecated-discard",
Status::DeprecatedDefault => "deprecated-default"
}, call.head),
"description" => Value::string(option.description(), call.head),
},
call.head,
)
})
.collect(),
call.head,
),
None,
))
}
}

View File

@ -1,6 +1,7 @@
mod ast;
mod debug_;
mod env;
mod experimental_options;
mod explain;
mod info;
mod inspect;
@ -21,6 +22,7 @@ mod view_span;
pub use ast::Ast;
pub use debug_::Debug;
pub use env::DebugEnv;
pub use experimental_options::DebugExperimentalOptions;
pub use explain::Explain;
pub use info::DebugInfo;
pub use inspect::Inspect;

View File

@ -153,6 +153,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
Ast,
Debug,
DebugEnv,
DebugExperimentalOptions,
DebugInfo,
DebugProfile,
Explain,