diff --git a/crates/nu-cmd-extra/src/extra/bits/into.rs b/crates/nu-cmd-extra/src/extra/bits/into.rs deleted file mode 100644 index d3979f0e47..0000000000 --- a/crates/nu-cmd-extra/src/extra/bits/into.rs +++ /dev/null @@ -1,120 +0,0 @@ -use nu_engine::command_prelude::*; - -use nu_protocol::{report_parse_warning, ParseWarning}; - -#[derive(Clone)] -pub struct BitsInto; - -impl Command for BitsInto { - fn name(&self) -> &str { - "into bits" - } - - fn signature(&self) -> Signature { - Signature::build("into bits") - .input_output_types(vec![ - (Type::Binary, Type::String), - (Type::Int, Type::String), - (Type::Filesize, Type::String), - (Type::Duration, Type::String), - (Type::String, Type::String), - (Type::Bool, Type::String), - (Type::table(), Type::table()), - (Type::record(), Type::record()), - ]) - .allow_variants_without_examples(true) // TODO: supply exhaustive examples - .rest( - "rest", - SyntaxShape::CellPath, - "For a data structure input, convert data at the given cell paths.", - ) - .category(Category::Deprecated) - } - - fn description(&self) -> &str { - "Convert value to a binary string." - } - - fn search_terms(&self) -> Vec<&str> { - vec![] - } - - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - let head = call.head; - report_parse_warning( - &StateWorkingSet::new(engine_state), - &ParseWarning::DeprecatedWarning { - old_command: "into bits".into(), - new_suggestion: "use `format bits`".into(), - span: head, - url: "`help format bits`".into(), - }, - ); - crate::extra::strings::format::format_bits(engine_state, stack, call, input) - } - - fn examples(&self) -> Vec { - vec![ - Example { - description: "convert a binary value into a string, padded to 8 places with 0s", - example: "0x[1] | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert an int into a string, padded to 8 places with 0s", - example: "1 | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a filesize value into a string, padded to 8 places with 0s", - example: "1b | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a duration value into a string, padded to 8 places with 0s", - example: "1ns | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a boolean value into a string, padded to 8 places with 0s", - example: "true | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a string into a raw binary string, padded with 0s to 8 places", - example: "'nushell.sh' | into bits", - result: Some(Value::string("01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000", - Span::test_data(), - )), - }, - ] - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_examples() { - use crate::test_examples; - - test_examples(BitsInto {}) - } -} diff --git a/crates/nu-cmd-extra/src/extra/bits/mod.rs b/crates/nu-cmd-extra/src/extra/bits/mod.rs index 145d66d777..437313960e 100644 --- a/crates/nu-cmd-extra/src/extra/bits/mod.rs +++ b/crates/nu-cmd-extra/src/extra/bits/mod.rs @@ -1,6 +1,5 @@ mod and; mod bits_; -mod into; mod not; mod or; mod rotate_left; @@ -11,7 +10,6 @@ mod xor; pub use and::BitsAnd; pub use bits_::Bits; -pub use into::BitsInto; pub use not::BitsNot; pub use or::BitsOr; pub use rotate_left::BitsRol; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index 74b12ee74c..4dfcbdcfef 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -5,9 +5,7 @@ mod math; mod platform; mod strings; -pub use bits::{ - Bits, BitsAnd, BitsInto, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor, -}; +pub use bits::{Bits, BitsAnd, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor}; pub use formats::ToHtml; pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH}; pub use math::{MathCos, MathCosH, MathSin, MathSinH, MathTan, MathTanH}; @@ -60,7 +58,6 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { bind_command! { Bits, BitsAnd, - BitsInto, BitsNot, BitsOr, BitsRol, diff --git a/crates/nu-cmd-extra/src/extra/strings/format/bits.rs b/crates/nu-cmd-extra/src/extra/strings/format/bits.rs index 1010477139..04390197cb 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/bits.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/bits.rs @@ -111,8 +111,7 @@ impl Command for FormatBits { } } -// TODO: crate public only during deprecation -pub(crate) fn format_bits( +fn format_bits( engine_state: &EngineState, stack: &mut Stack, call: &Call, diff --git a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs index e55c96685c..f032474edf 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs @@ -2,7 +2,6 @@ mod bits; mod command; mod number; +pub(crate) use bits::FormatBits; pub(crate) use command::FormatPattern; -// TODO remove `format_bits` visibility after removal of into bits -pub(crate) use bits::{format_bits, FormatBits}; pub(crate) use number::FormatNumber;