diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index abb0ce1a2b..bc1d5bcf11 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -40,7 +40,7 @@ impl Command for SubCommand { "For a data structure input, check strings at the given cell paths, and replace with result.", ) .switch("ignore-case", "search is case insensitive", Some('i')) - .switch("not", "does not contain", Some('n')) + .switch("not", "DEPRECATED OPTION: does not contain", Some('n')) .category(Category::Strings) } @@ -59,6 +59,20 @@ impl Command for SubCommand { call: &Call, input: PipelineData, ) -> Result { + if call.has_flag(engine_state, stack, "not")? { + nu_protocol::report_error_new( + engine_state, + &ShellError::GenericError { + error: "Deprecated option".into(), + msg: "`str contains --not {string}` is deprecated and will be removed in 0.95." + .into(), + span: Some(call.head), + help: Some("Please use the `not` operator instead.".into()), + inner: vec![], + }, + ); + } + let cell_paths: Vec = call.rest(engine_state, stack, 1)?; let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths); let args = Arguments { @@ -120,15 +134,6 @@ impl Command for SubCommand { Value::test_bool(false), ])), }, - Example { - description: "Check if list does not contain string", - example: "[one two three] | str contains --not o", - result: Some(Value::test_list(vec![ - Value::test_bool(false), - Value::test_bool(false), - Value::test_bool(true), - ])), - }, ] } }