nu_command/debug/
experimental_options.rs1use nu_engine::command_prelude::*;
2use nu_experimental::Status;
3
4#[derive(Clone)]
5pub struct DebugExperimentalOptions;
6
7impl Command for DebugExperimentalOptions {
8 fn name(&self) -> &str {
9 "debug experimental-options"
10 }
11
12 fn signature(&self) -> Signature {
13 Signature::new(self.name())
14 .input_output_type(
15 Type::Nothing,
16 Type::Table(Box::from([
17 (String::from("identifier"), Type::String),
18 (String::from("enabled"), Type::Bool),
19 (String::from("status"), Type::String),
20 (String::from("description"), Type::String),
21 ])),
22 )
23 .add_help()
24 .category(Category::Debug)
25 }
26
27 fn description(&self) -> &str {
28 "Show all experimental options."
29 }
30
31 fn run(
32 &self,
33 _engine_state: &EngineState,
34 _stack: &mut Stack,
35 call: &Call,
36 _input: PipelineData,
37 ) -> Result<PipelineData, ShellError> {
38 Ok(PipelineData::value(
39 Value::list(
40 nu_experimental::ALL
41 .iter()
42 .map(|option| {
43 Value::record(
44 nu_protocol::record! {
45 "identifier" => Value::string(option.identifier(), call.head),
46 "enabled" => Value::bool(option.get(), call.head),
47 "status" => Value::string(match option.status() {
48 Status::OptIn => "opt-in",
49 Status::OptOut => "opt-out",
50 Status::DeprecatedDiscard => "deprecated-discard",
51 Status::DeprecatedDefault => "deprecated-default"
52 }, call.head),
53 "description" => Value::string(option.description(), call.head),
54 },
55 call.head,
56 )
57 })
58 .collect(),
59 call.head,
60 ),
61 None,
62 ))
63 }
64}