forked from extern/nushell
cc/ @stormasm # Description i was about to start the cratification of the 0% commands and thought i could refactor and simplify a bit the declaration of the `bits` commands, having hopefully a simpler structure to work with the other commands 😌 this PR: - gives real names to all the `bits` commands, instead of `SubCommand` - make them publicly available inside the `nu-cmd-extra` crate to declare them through `add_extra_decls` - move the declaration code to the top-level `mod.nu` of `nu-cmd-extra` so that all commands can be declared there as in `default_context` in `nu-command` # User-Facing Changes ``` $nothing ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - ⚫ `toolkit test` - ⚫ `toolkit test stdlib` # After Submitting ``` $nothing ```
27 lines
694 B
Rust
27 lines
694 B
Rust
mod bits;
|
|
|
|
use nu_protocol::engine::StateWorkingSet;
|
|
|
|
pub fn add_extra_decls(working_set: &mut StateWorkingSet) {
|
|
macro_rules! bind_command {
|
|
( $command:expr ) => {
|
|
working_set.add_decl(Box::new($command));
|
|
};
|
|
( $( $command:expr ),* ) => {
|
|
$( working_set.add_decl(Box::new($command)); )*
|
|
};
|
|
}
|
|
|
|
bind_command!(
|
|
bits::bits_::Bits,
|
|
bits::and::BitsAnd,
|
|
bits::not::BitsNot,
|
|
bits::or::BitsOr,
|
|
bits::xor::BitsXor,
|
|
bits::rotate_left::BitsRol,
|
|
bits::rotate_right::BitsRor,
|
|
bits::shift_left::BitsShl,
|
|
bits::shift_right::BitsShr
|
|
);
|
|
}
|