mirror of
https://github.com/nushell/nushell.git
synced 2025-04-16 09:18:21 +02:00
Remove into bits
after deprecation (#15039)
# Description Follow up to https://github.com/nushell/nushell/pull/14634 # User-Facing Changes `into bits` will be gone for good. Use it under the new name `format bits` ## Note Can be removed ahead of the `0.103.0` release as it was deprecated with `0.102.0`
This commit is contained in:
parent
7f346dbf4c
commit
9160f36ea5
@ -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<PipelineData, ShellError> {
|
|
||||||
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<Example> {
|
|
||||||
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 {})
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
mod and;
|
mod and;
|
||||||
mod bits_;
|
mod bits_;
|
||||||
mod into;
|
|
||||||
mod not;
|
mod not;
|
||||||
mod or;
|
mod or;
|
||||||
mod rotate_left;
|
mod rotate_left;
|
||||||
@ -11,7 +10,6 @@ mod xor;
|
|||||||
|
|
||||||
pub use and::BitsAnd;
|
pub use and::BitsAnd;
|
||||||
pub use bits_::Bits;
|
pub use bits_::Bits;
|
||||||
pub use into::BitsInto;
|
|
||||||
pub use not::BitsNot;
|
pub use not::BitsNot;
|
||||||
pub use or::BitsOr;
|
pub use or::BitsOr;
|
||||||
pub use rotate_left::BitsRol;
|
pub use rotate_left::BitsRol;
|
||||||
|
@ -5,9 +5,7 @@ mod math;
|
|||||||
mod platform;
|
mod platform;
|
||||||
mod strings;
|
mod strings;
|
||||||
|
|
||||||
pub use bits::{
|
pub use bits::{Bits, BitsAnd, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor};
|
||||||
Bits, BitsAnd, BitsInto, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor,
|
|
||||||
};
|
|
||||||
pub use formats::ToHtml;
|
pub use formats::ToHtml;
|
||||||
pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH};
|
pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH};
|
||||||
pub use math::{MathCos, MathCosH, MathSin, MathSinH, MathTan, MathTanH};
|
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! {
|
bind_command! {
|
||||||
Bits,
|
Bits,
|
||||||
BitsAnd,
|
BitsAnd,
|
||||||
BitsInto,
|
|
||||||
BitsNot,
|
BitsNot,
|
||||||
BitsOr,
|
BitsOr,
|
||||||
BitsRol,
|
BitsRol,
|
||||||
|
@ -111,8 +111,7 @@ impl Command for FormatBits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: crate public only during deprecation
|
fn format_bits(
|
||||||
pub(crate) fn format_bits(
|
|
||||||
engine_state: &EngineState,
|
engine_state: &EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
call: &Call,
|
call: &Call,
|
||||||
|
@ -2,7 +2,6 @@ mod bits;
|
|||||||
mod command;
|
mod command;
|
||||||
mod number;
|
mod number;
|
||||||
|
|
||||||
|
pub(crate) use bits::FormatBits;
|
||||||
pub(crate) use command::FormatPattern;
|
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;
|
pub(crate) use number::FormatNumber;
|
||||||
|
Loading…
Reference in New Issue
Block a user