Skip to content

Commit

Permalink
Deprecate split-by command (nushell#14019)
Browse files Browse the repository at this point in the history
# Description
I'm not quite sure what the point of the `split-by` command is. The only
example for the command seems to suggest it's an additional grouping
command. I.e., a record that seems to be the output of the `group-by`
command is passed to `split-by` which then adds an additional layer of
grouping based on a different column.

# User-Facing Changes
Breaking change, deprecated the command.
  • Loading branch information
IanManske authored Nov 21, 2024
1 parent 4ed25b6 commit d8c2493
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions crates/nu-command/src/filters/split_by.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use indexmap::IndexMap;
use nu_engine::command_prelude::*;
use nu_protocol::report_shell_warning;

#[derive(Clone)]
pub struct SplitBy;
Expand Down Expand Up @@ -27,6 +28,15 @@ impl Command for SplitBy {
call: &Call,
input: PipelineData,
) -> Result<PipelineData, ShellError> {
report_shell_warning(
engine_state,
&ShellError::Deprecated {
deprecated: "The `split_by` command",
suggestion: "Please use the `group-by` command instead.",
span: call.head,
help: None,
},
);
split_by(engine_state, stack, call, input)
}

Expand Down
13 changes: 7 additions & 6 deletions crates/nu-protocol/src/errors/shell_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,14 +1330,15 @@ This is an internal Nushell error, please file an issue https://github.com/nushe
span: Span,
},

#[error("Deprecated: {old_command}")]
#[diagnostic(help("for more info see {url}"))]
#[error("{deprecated} is deprecated and will be removed in a future release")]
#[diagnostic()]
Deprecated {
old_command: String,
new_suggestion: String,
#[label("`{old_command}` is deprecated and will be removed in a future release. Please {new_suggestion} instead.")]
deprecated: &'static str,
suggestion: &'static str,
#[label("{deprecated} is deprecated. {suggestion}")]
span: Span,
url: String,
#[help]
help: Option<&'static str>,
},

/// Invalid glob pattern
Expand Down

0 comments on commit d8c2493

Please sign in to comment.