nushell/crates/nu-command/src/platform
Antoine Stevan 427db0d101
FEATURE: better ansi -e error (#8709)
Should close #8704.

# Description
this PR
- makes the error thrown by things like `ansi -e {invalid: "invalid"}`
more explicit
- makes the `ansi -e` example more explicit about valid / invalid keys

# User-Facing Changes
the error
```bash
> ansi -e {invalid: "invalid"}
Error: nu:🐚:incompatible_parameters

  × Incompatible parameters.
   ╭─[entry #1:1:1]
 1 │ ansi -e {invalid: "invalid"}
   ·         ──────────┬─────────
   ·                   ╰── unknown ANSI format key: expected one of ['fg', 'bg', 'attr'], found 'invalid'
   ╰────
```

the new `ansi -e` example
```bash
  Use structured escape codes
  > let bold_blue_on_red = {  # `fg`, `bg`, `attr` are the acceptable keys, all other keys are considered invalid and will throw errors.
        fg: '#0000ff'
        bg: '#ff0000'
        attr: b
    }
    $"(ansi -e $bold_blue_on_red)Hello Nu World(ansi reset)"
  Hello Nu World
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-05 23:14:39 +02:00
..
ansi FEATURE: better ansi -e error (#8709) 2023-04-05 23:14:39 +02:00
reedline_commands Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
clear.rs Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
dir_info.rs Further cleanup of Span::test_data usage + span fixes (#7595) 2022-12-24 07:41:57 -06:00
du.rs Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
input.rs interrupt input command with Ctrl + C (#8159) 2023-02-22 17:19:19 +00:00
kill.rs Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
mod.rs Ansi link (#7751) 2023-01-15 17:23:37 +02:00
sleep.rs Add helper method to check whether ctrl+c was pressed, adopt it (#7482) 2022-12-15 09:39:24 -08:00
term_size.rs Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00