nushell/crates/nu-command/src
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
..
bits Require that values that look like numbers parse as numberlike (#8635) 2023-03-28 19:31:38 +13:00
bytes make bytes at use ranges (#8710) 2023-04-03 04:28:36 +12:00
charting fix: fixed typo and improved Value TypeMismatch exceptions (#8324) 2023-03-22 09:47:40 +01:00
conversions Fix a bug with us not outputting as µs with the into duration command (#8691) 2023-03-31 16:01:48 -05:00
database Add pattern matching (#8590) 2023-03-24 14:52:01 +13:00
dataframe docs: Use capital letters for CSV and JSON acronyms (#8459) 2023-03-15 21:52:13 -07:00
date Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
debug Fix of a fix of #8671 (#8675) 2023-03-31 07:53:57 -05:00
deprecated Allow NU_LIBS_DIR and friends to be const (#8538) 2023-04-05 19:56:48 +03:00
env Allow NU_LIBS_DIR and friends to be const (#8538) 2023-04-05 19:56:48 +03:00
experimental Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
filesystem Better error message for mv when file not found (#8586) 2023-03-23 11:31:49 -07:00
filters Add section on removing ANSI sequences with find command (#8519) 2023-04-05 20:26:20 +03:00
formats Fix two stable clippy lints (#8712) 2023-04-02 16:23:19 +02:00
generators Document and critically review ShellError variants - Ep. 2 (#8326) 2023-03-06 11:31:07 +01:00
hash Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
math Add math exp command (issue #8661) (#8700) 2023-04-01 12:53:58 +02:00
misc Uniformize usage() and extra_usage() message ending for commands helper. (#8268) 2023-02-28 21:33:02 -08:00
network Fix record-to-JSON conversion for HTTP commands (#8663) 2023-03-29 11:55:51 -07:00
path Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
platform FEATURE: better ansi -e error (#8709) 2023-04-05 23:14:39 +02:00
random Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
shells Require that values that look like numbers parse as numberlike (#8635) 2023-03-28 19:31:38 +13:00
strings make bytes at use ranges (#8710) 2023-04-03 04:28:36 +12:00
system Add ppid to ps command (#8750) 2023-04-05 13:12:01 -05:00
viewers Require that values that look like numbers parse as numberlike (#8635) 2023-03-28 19:31:38 +13:00
default_context.rs Add math exp command (issue #8661) (#8700) 2023-04-01 12:53:58 +02:00
example_test.rs cratification: Example support (#8231) 2023-02-27 13:58:56 -08:00
hook.rs Move variables to var stack (#8604) 2023-03-25 12:56:45 +13:00
input_handler.rs Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
lib.rs feat: add a command_not_found hook (#8314) 2023-03-20 17:05:22 +13:00
progress_bar.rs cp progress bar implementation (#8012) 2023-02-22 11:57:38 -08:00
sort_utils.rs Support passing an empty list to sort, uniq, sort-by, and uniq-by (issue #5957) (#8669) 2023-03-29 19:55:38 -07:00
util.rs make bytes at use ranges (#8710) 2023-04-03 04:28:36 +12:00