[formatter] How to escape end expressions to handle JSON braces?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start at CLI::UI.puts and reproduce the formatter behavior with the hash and command examples in the issue. Trace how end expressions are parsed and determine how literal braces should be escaped or preserved; done means the closing braces remain present and receive the intended color.
Written by the indexing model from the issue text.
Description
Is there a way to color text and escape any braces in it?
Problem: ending braces aren't getting color or they're getting removed:
hash = {wtv: 3}
CLI::UI.puts("{{magenta:#{hash}}}") # last brace is not colored
hash2 = {wtv: {key: 3}}
CLI::UI.puts("{{magenta:#{hash2}}}") # last 2 braces are missing: "{wtv: {key: 3"
Here's one work-around I found:
CLI::UI.puts("#{CLI::UI::Color::MAGENTA.code}#{hash}", format: false)
Update: The work-around isn't as easy to do for command formatting, unless you wanna assume that commands are always cyan:
CLI::UI.puts("{{command:run { {json}}}}") # omits the ending "}}"
CLI::UI.puts("\e[#{CLI::UI::Formatter::SGR_MAP['command']}mrun { {json}}", format: false) # works
Update 2:
Using colorize also helps.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 57
- Avg merge
- 2h 55m
- Merged PRs (30d)
- 2
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/cli-ui
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solana-foundation/pay-kit#341 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Cask still fails to install: `depends_on macos: :catalina` is now disabled (regression after #58)Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100