Remove fmt after deprecation (#15040)

# Description
Follow up to https://github.com/nushell/nushell/pull/14875
# User-Facing Changes
`fmt` will be gone for good.

Use it under the new name `format number`

## Note
Can be removed ahead of the `0.103.0` release as it was deprecated with
`0.102.0`
This commit is contained in:
Stefan Holderbach 2025-03-12 21:43:12 +01:00 committed by GitHub
parent 03888b9d81
commit 7f346dbf4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1 additions and 82 deletions

View File

@ -1,74 +0,0 @@
use nu_engine::command_prelude::*;
use nu_protocol::{report_parse_warning, ParseWarning};
#[derive(Clone)]
pub struct Fmt;
impl Command for Fmt {
fn name(&self) -> &str {
"fmt"
}
fn description(&self) -> &str {
"Format a number."
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("fmt")
.input_output_types(vec![(Type::Number, Type::record())])
.category(Category::Deprecated)
}
fn search_terms(&self) -> Vec<&str> {
vec![]
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Get a record containing multiple formats for the number 42",
example: "42 | fmt",
result: Some(Value::test_record(record! {
"binary" => Value::test_string("0b101010"),
"debug" => Value::test_string("42"),
"display" => Value::test_string("42"),
"lowerexp" => Value::test_string("4.2e1"),
"lowerhex" => Value::test_string("0x2a"),
"octal" => Value::test_string("0o52"),
"upperexp" => Value::test_string("4.2E1"),
"upperhex" => Value::test_string("0x2A"),
})),
}]
}
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: "fmt".into(),
new_suggestion: "use `format number`".into(),
span: head,
url: "`help format number`".into(),
},
);
crate::extra::strings::format::format_number(engine_state, stack, call, input)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_examples() {
use crate::test_examples;
test_examples(Fmt {})
}
}

View File

@ -1,3 +0,0 @@
mod fmt;
pub(crate) use fmt::Fmt;

View File

@ -1,5 +1,4 @@
mod bits;
mod conversions;
mod filters;
mod formats;
mod math;
@ -29,8 +28,6 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
};
}
bind_command!(conversions::Fmt);
bind_command!(
filters::UpdateCells,
filters::EachWhile,

View File

@ -5,5 +5,4 @@ mod number;
pub(crate) use command::FormatPattern;
// TODO remove `format_bits` visibility after removal of into bits
pub(crate) use bits::{format_bits, FormatBits};
// TODO remove `format_number` visibility after removal of into bits
pub(crate) use number::{format_number, FormatNumber};
pub(crate) use number::FormatNumber;