nushell/crates/nu-command/tests/string/format
Loïc Riegel 58a8f30a25
small refactoring around units and add tests (#15746)
Closes #14469

# Description
- ~~Implement the ``--unit`` conversion in "into int" command~~
- New ``ShellError::InvalidUnit`` unit if users enter wrong units
- Made ``ShellError::CantConvertToDuration`` more generic: became
``CantConvertToUnit``
- Tried to improve the way we parse units and get the supported units.
It's not complete, though, I will continue this refactoring in another
PR. But I already did some small refactorings in the "format duration"
and "format filesize" commands
- Add tests for "format filesize" and "format duration"

# User-Facing Changes

```nu
~> 1MB | format filesize sec
Error: nu:🐚:invalid_unit

  × Invalid unit
   ╭─[entry #7:1:23]
 1 │ 1MB | format filesize sec
   ·                       ─┬─
   ·                        ╰── encountered here
   ╰────
  help: Supported units are: B, kB, MB, GB, TB, PB, EB, KiB, MiB, GiB, TiB, PiB, EiB

```
2025-05-16 17:41:26 -05:00
..
duration.rs small refactoring around units and add tests (#15746) 2025-05-16 17:41:26 -05:00
filesize.rs small refactoring around units and add tests (#15746) 2025-05-16 17:41:26 -05:00
mod.rs small refactoring around units and add tests (#15746) 2025-05-16 17:41:26 -05:00