nu_cmd_extra/extra/
mod.rs

1mod bits;
2mod filters;
3mod formats;
4mod math;
5mod platform;
6mod strings;
7
8pub use bits::{Bits, BitsAnd, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor};
9pub use formats::ToHtml;
10pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH};
11pub use math::{MathCos, MathCosH, MathSin, MathSinH, MathTan, MathTanH};
12pub use math::{MathExp, MathLn};
13
14use nu_protocol::engine::{EngineState, StateWorkingSet};
15
16pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
17    let delta = {
18        let mut working_set = StateWorkingSet::new(&engine_state);
19
20        macro_rules! bind_command {
21            ( $command:expr ) => {
22                working_set.add_decl(Box::new($command));
23            };
24            ( $( $command:expr ),* ) => {
25                $( working_set.add_decl(Box::new($command)); )*
26            };
27        }
28
29        bind_command!(
30            filters::UpdateCells,
31            filters::EachWhile,
32            filters::Roll,
33            filters::RollDown,
34            filters::RollUp,
35            filters::RollLeft,
36            filters::RollRight,
37            filters::Rotate
38        );
39
40        bind_command!(platform::ansi::Gradient);
41
42        bind_command!(
43            strings::format::FormatPattern,
44            strings::format::FormatBits,
45            strings::format::FormatNumber,
46            strings::str_::case::Str,
47            strings::str_::case::StrCamelCase,
48            strings::str_::case::StrKebabCase,
49            strings::str_::case::StrPascalCase,
50            strings::str_::case::StrScreamingSnakeCase,
51            strings::str_::case::StrSnakeCase,
52            strings::str_::case::StrTitleCase
53        );
54
55        bind_command!(ToHtml, formats::FromUrl);
56
57        // Bits
58        bind_command! {
59            Bits,
60            BitsAnd,
61            BitsNot,
62            BitsOr,
63            BitsRol,
64            BitsRor,
65            BitsShl,
66            BitsShr,
67            BitsXor
68        }
69
70        // Math
71        bind_command! {
72            MathArcSin,
73            MathArcCos,
74            MathArcTan,
75            MathArcSinH,
76            MathArcCosH,
77            MathArcTanH,
78            MathSin,
79            MathCos,
80            MathTan,
81            MathSinH,
82            MathCosH,
83            MathTanH,
84            MathExp,
85            MathLn
86        };
87
88        working_set.render()
89    };
90
91    if let Err(err) = engine_state.merge_delta(delta) {
92        eprintln!("Error creating extra command context: {err:?}");
93    }
94
95    engine_state
96}