mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 03:34:58 +02:00
Add infrastructure for experimental options (#16028)
Co-authored-by: Bahex <Bahex@users.noreply.github.com>
This commit is contained in:
@ -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 }
|
||||
|
64
crates/nu-command/src/debug/experimental_options.rs
Normal file
64
crates/nu-command/src/debug/experimental_options.rs
Normal 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,
|
||||
))
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -153,6 +153,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
||||
Ast,
|
||||
Debug,
|
||||
DebugEnv,
|
||||
DebugExperimentalOptions,
|
||||
DebugInfo,
|
||||
DebugProfile,
|
||||
Explain,
|
||||
|
Reference in New Issue
Block a user