Skip to content

FEATURE: better ansi -e error #8709

Merged
sholderbach merged 4 commits intonushell:mainfrom
amtoine:feature/better-ansi-e-error
Apr 5, 2023
Merged

FEATURE: better ansi -e error #8709
sholderbach merged 4 commits intonushell:mainfrom
amtoine:feature/better-ansi-e-error

Conversation

@amtoine
Copy link
Copy Markdown
Member

@amtoine amtoine commented Apr 2, 2023

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

> ansi -e {invalid: "invalid"}
Error: nu::shell::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

  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

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 5, 2023

apparently there are conflicts to resolve, or i'd land this.

…better-ansi-e-error

This solves the merge conflicts.
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Apr 5, 2023

apparently there are conflicts to resolve, or i'd land this.

should be fixed in e926354 😋

if the tests pass, i think we're good with these new errors 💪

@sholderbach sholderbach merged commit 427db0d into nushell:main Apr 5, 2023
@amtoine amtoine deleted the feature/better-ansi-e-error branch April 6, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve the errors in ansi -e

3 participants