mirror of
https://github.com/nushell/nushell.git
synced 2025-02-28 00:12:36 +01:00
### What? This change removes 3 flags (`--all`, `--both`, and `--format`) from `str trim`. This is a net reduction of ~450 LoC and `str trim` no longer depends on `fancy_regex`. ### Why? I found these flags to be quite confusing when reviewing `str trim` earlier today: 1. `--all` removes characters even if they're in the centre of the the string. - This is arguably not "trimming"! In all programming languages I'm familiar with, trimming only affects the start and end of a string. - If someone needs to do this, `str replace` is more natural IMO 2. `--both` trims from the left and right - Confusing and unnecessary given that this is also the default behaviour 3. `--format` replaces multiple spaces with a single space, even in the centre of the string - Again, I don't think this falls under the scope of "trimming". IMO `str replace` is a more natural fit I believe that `str trim` is simpler and easier to understand after this change. ### Before ``` 〉help str trim Trim whitespace or specific character Search terms: whitespace, strip, lstrip, rstrip Usage: > str trim {flags} ...(rest) Flags: -h, --help - Display the help message for this command -c, --char <String> - character to trim (default: whitespace) -l, --left - trims characters only from the beginning of the string -r, --right - trims characters only from the end of the string -a, --all - trims all characters from both sides of the string *and* in the middle -b, --both - trims all characters from left and right side of the string -f, --format - trims spaces replacing multiple characters with singles in the middle ``` ### After ``` 〉help str trim Trim whitespace or specific character Search terms: whitespace, strip, lstrip, rstrip Usage: > str trim {flags} ...(rest) Flags: -h, --help - Display the help message for this command -c, --char <String> - character to trim (default: whitespace) -l, --left - trims characters only from the beginning of the string -r, --right - trims characters only from the end of the string ``` |
||
---|---|---|
.. | ||
encode_decode | ||
format | ||
split | ||
str_ | ||
char_.rs | ||
detect_columns.rs | ||
mod.rs | ||
parse.rs | ||
size.rs |