mirror of
https://github.com/nushell/nushell
synced 2025-01-13 21:55:07 +00:00
Remove str deunicode
(#13693)
# Description Closes #13677 Remove the command `str deunicode`, as it has a narrow application, is loosely defined by the data provided by the `deunicode` crate and thus a stabilization liability post-1.0. Furthermore the data to perform the look-up is quite substantial. Removing the command and the `deunicode` dependency saves 0.9 MB of binary data in release mode (~ 2% of total) (checked via `cargo bloat --release` for a linux x86 build) # User-Facing Changes The `str deunicode` command recently added in #13270 is gone
This commit is contained in:
parent
7dda39a89e
commit
af76e11dd6
6 changed files with 0 additions and 110 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -1197,12 +1197,6 @@ dependencies = [
|
||||||
"syn 2.0.75",
|
"syn 2.0.75",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deunicode"
|
|
||||||
version = "1.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dialoguer"
|
name = "dialoguer"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
@ -3123,7 +3117,6 @@ dependencies = [
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"csv",
|
"csv",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
"deunicode",
|
|
||||||
"dialoguer",
|
"dialoguer",
|
||||||
"digest",
|
"digest",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
|
|
@ -81,7 +81,6 @@ crossbeam-channel = "0.5.8"
|
||||||
crossterm = "0.27"
|
crossterm = "0.27"
|
||||||
csv = "1.3"
|
csv = "1.3"
|
||||||
ctrlc = "3.4"
|
ctrlc = "3.4"
|
||||||
deunicode = "1.6.0"
|
|
||||||
dialoguer = { default-features = false, version = "0.11" }
|
dialoguer = { default-features = false, version = "0.11" }
|
||||||
digest = { default-features = false, version = "0.10" }
|
digest = { default-features = false, version = "0.10" }
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
|
|
|
@ -42,7 +42,6 @@ chrono-humanize = { workspace = true }
|
||||||
chrono-tz = { workspace = true }
|
chrono-tz = { workspace = true }
|
||||||
crossterm = { workspace = true }
|
crossterm = { workspace = true }
|
||||||
csv = { workspace = true }
|
csv = { workspace = true }
|
||||||
deunicode = { workspace = true }
|
|
||||||
dialoguer = { workspace = true, default-features = false, features = ["fuzzy-select"] }
|
dialoguer = { workspace = true, default-features = false, features = ["fuzzy-select"] }
|
||||||
digest = { workspace = true, default-features = false }
|
digest = { workspace = true, default-features = false }
|
||||||
dtparse = { workspace = true }
|
dtparse = { workspace = true }
|
||||||
|
|
|
@ -199,7 +199,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
||||||
Str,
|
Str,
|
||||||
StrCapitalize,
|
StrCapitalize,
|
||||||
StrContains,
|
StrContains,
|
||||||
StrDeunicode,
|
|
||||||
StrDistance,
|
StrDistance,
|
||||||
StrDowncase,
|
StrDowncase,
|
||||||
StrEndswith,
|
StrEndswith,
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
use deunicode::deunicode;
|
|
||||||
use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs};
|
|
||||||
use nu_engine::command_prelude::*;
|
|
||||||
use nu_protocol::engine::StateWorkingSet;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SubCommand;
|
|
||||||
|
|
||||||
impl Command for SubCommand {
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"str deunicode"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
|
||||||
Signature::build("str deunicode")
|
|
||||||
.input_output_types(vec![(Type::String, Type::String)])
|
|
||||||
.category(Category::Strings)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
"Convert Unicode string to pure ASCII."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
|
||||||
vec!["convert", "ascii"]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_const(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run(
|
|
||||||
&self,
|
|
||||||
engine_state: &EngineState,
|
|
||||||
stack: &mut Stack,
|
|
||||||
call: &Call,
|
|
||||||
input: PipelineData,
|
|
||||||
) -> Result<PipelineData, ShellError> {
|
|
||||||
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
|
|
||||||
let args = CellPathOnlyArgs::from(cell_paths);
|
|
||||||
|
|
||||||
operate(action, args, input, call.head, engine_state.signals())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_const(
|
|
||||||
&self,
|
|
||||||
working_set: &StateWorkingSet,
|
|
||||||
call: &Call,
|
|
||||||
input: PipelineData,
|
|
||||||
) -> Result<PipelineData, ShellError> {
|
|
||||||
let cell_paths: Vec<CellPath> = call.rest_const(working_set, 0)?;
|
|
||||||
let args = CellPathOnlyArgs::from(cell_paths);
|
|
||||||
|
|
||||||
operate(
|
|
||||||
action,
|
|
||||||
args,
|
|
||||||
input,
|
|
||||||
call.head,
|
|
||||||
working_set.permanent().signals(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
|
||||||
vec![Example {
|
|
||||||
description: "deunicode a string",
|
|
||||||
example: "'A…B' | str deunicode",
|
|
||||||
result: Some(Value::test_string("A...B")),
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn action(input: &Value, _args: &CellPathOnlyArgs, head: Span) -> Value {
|
|
||||||
match input {
|
|
||||||
Value::String { val, .. } => Value::string(deunicode(val), head),
|
|
||||||
Value::Error { .. } => input.clone(),
|
|
||||||
_ => Value::error(
|
|
||||||
ShellError::OnlySupportsThisInputType {
|
|
||||||
exp_input_type: "string".into(),
|
|
||||||
wrong_type: input.get_type().to_string(),
|
|
||||||
dst_span: head,
|
|
||||||
src_span: input.span(),
|
|
||||||
},
|
|
||||||
head,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_examples() {
|
|
||||||
use crate::test_examples;
|
|
||||||
|
|
||||||
test_examples(SubCommand {})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
mod case;
|
mod case;
|
||||||
mod contains;
|
mod contains;
|
||||||
mod deunicode;
|
|
||||||
mod distance;
|
mod distance;
|
||||||
mod ends_with;
|
mod ends_with;
|
||||||
mod expand;
|
mod expand;
|
||||||
|
@ -16,7 +15,6 @@ mod trim;
|
||||||
|
|
||||||
pub use case::*;
|
pub use case::*;
|
||||||
pub use contains::SubCommand as StrContains;
|
pub use contains::SubCommand as StrContains;
|
||||||
pub use deunicode::SubCommand as StrDeunicode;
|
|
||||||
pub use distance::SubCommand as StrDistance;
|
pub use distance::SubCommand as StrDistance;
|
||||||
pub use ends_with::SubCommand as StrEndswith;
|
pub use ends_with::SubCommand as StrEndswith;
|
||||||
pub use expand::SubCommand as StrExpand;
|
pub use expand::SubCommand as StrExpand;
|
||||||
|
|
Loading…
Reference in a new issue