Skip to content

Commit

Permalink
Remove str replace --string after deprecation (#10064)
Browse files Browse the repository at this point in the history
related to
- #10038

# Description
`str replace --string` has been deprecated in
#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.
  • Loading branch information
amtoine committed Sep 19, 2023
1 parent 01ade02 commit f8939de
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions crates/nu-command/src/strings/str_/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use nu_engine::CallExt;
use nu_protocol::{
ast::{Call, CellPath},
engine::{Command, EngineState, Stack},
report_error_new, Category, Example, PipelineData, Record, ShellError, Signature, Span,
Spanned, SyntaxShape, Type, Value,
Category, Example, PipelineData, Record, ShellError, Signature, Span, Spanned, SyntaxShape,
Type, Value,
};

struct Arguments {
Expand Down Expand Up @@ -57,11 +57,6 @@ impl Command for SubCommand {
"do not expand capture groups (like $name) in the replacement string",
Some('n'),
)
.switch(
"string",
"DEPRECATED option, will be removed in 0.85. Substring matching is now the default.",
Some('s'),
)
.switch(
"regex",
"match the pattern as a regular expression in the input, instead of a substring",
Expand Down Expand Up @@ -96,18 +91,6 @@ impl Command for SubCommand {
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 2)?;
let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths);
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 multiline = call.has_flag("multiline");

Expand Down

0 comments on commit f8939de

Please sign in to comment.