Remove str replace --string after deprecation (#10064)

related to
- https://github.com/nushell/nushell/pull/10038

# Description
`str replace --string` has been deprecated in
https://github.com/nushell/nushell/pull/10038 and should be removed
before 0.85.

this PR removes the `--string` option from `str replace` completely.

# User-Facing Changes
`str replace --string` will no longer work and will give an error
instead of a warning.
This commit is contained in:
Antoine Stevan 2023-09-19 15:54:20 +02:00 committed by GitHub
parent 01ade02ac1
commit f8939de14f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,8 @@ use nu_engine::CallExt;
use nu_protocol::{ use nu_protocol::{
ast::{Call, CellPath}, ast::{Call, CellPath},
engine::{Command, EngineState, Stack}, engine::{Command, EngineState, Stack},
report_error_new, Category, Example, PipelineData, Record, ShellError, Signature, Span, Category, Example, PipelineData, Record, ShellError, Signature, Span, Spanned, SyntaxShape,
Spanned, SyntaxShape, Type, Value, Type, Value,
}; };
struct Arguments { struct Arguments {
@ -57,11 +57,6 @@ impl Command for SubCommand {
"do not expand capture groups (like $name) in the replacement string", "do not expand capture groups (like $name) in the replacement string",
Some('n'), Some('n'),
) )
.switch(
"string",
"DEPRECATED option, will be removed in 0.85. Substring matching is now the default.",
Some('s'),
)
.switch( .switch(
"regex", "regex",
"match the pattern as a regular expression in the input, instead of a substring", "match the pattern as a regular expression in the input, instead of a substring",
@ -96,18 +91,6 @@ impl Command for SubCommand {
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 2)?; let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 2)?;
let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths);
let literal_replace = call.has_flag("no-expand"); let literal_replace = call.has_flag("no-expand");
if call.has_flag("string") {
report_error_new(
engine_state,
&ShellError::GenericError(
"Deprecated option".into(),
"`str replace --string` is deprecated and will be removed in 0.85.".into(),
Some(call.head),
Some("Substring matching is now the default. Use `--regex` or `--multiline` for matching regular expressions.".into()),
vec![],
),
);
}
let no_regex = !call.has_flag("regex") && !call.has_flag("multiline"); let no_regex = !call.has_flag("regex") && !call.has_flag("multiline");
let multiline = call.has_flag("multiline"); let multiline = call.has_flag("multiline");