nushell/crates/nu-command/src/strings
Bahex fcd1d59abd
split list: add streaming, closure argument, and splitting before/after a separator (#15161)
- this PR addresses most of the points in #13153

# Description

- make `split list` support streaming
- **[BREAKING CHANGE]** if the input is split on consecutive items, the
empty lists between those items are preserved.
  e.g. `[1 1 0 0 3 3 0 4 4] | split list 0` == `[[1 1] [] [2 2] [3 3]]`
- accept a closure as argument, the closure is called for each item, and
if it returns `true` the list is split on that item
- added `--split` flag, which allows keeping the separator items.
`--split=after` splits the list *after* the separator and
`--split=before` splits the list *before* the separator.
  `--split=on` is the default behavior where the separator is lost

# User-Facing Changes

`split list`:
- keeps empty sublists
- allows using a closure to determine items to split on
- allows keeping the separator items with `--split=after` and
`--split=before`

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-02-23 07:53:38 -06:00
..
base Replace the old encode base64 and decode base64 with new-base64 commands (#14018) 2024-10-08 11:01:43 +08:00
encode_decode Drop once_cell dependency (#14198) 2024-10-29 17:33:46 +01:00
format Run-time pipeline input typechecking tweaks (#14922) 2025-02-02 15:51:47 -05:00
split split list: add streaming, closure argument, and splitting before/after a separator (#15161) 2025-02-23 07:53:38 -06:00
str_ Feature+: Bracoxide Zero Padding for Numeric Ranges (#15125) 2025-02-19 07:35:10 -06:00
char_.rs Fix char lsep assignment (#15065) 2025-02-09 07:19:11 -05:00
detect_columns.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
guess_width.rs fix: clippy warnings with --all-features (#15035) 2025-02-07 12:30:25 +01:00
mod.rs encode/decode for multiple alphabets (#13428) 2024-08-23 11:18:51 -05:00
parse.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00