Skip to content

Add colors to the CLI client#3058

Merged
stgraber merged 9 commits intolxc:mainfrom
bensmrs:colors
Mar 20, 2026
Merged

Add colors to the CLI client#3058
stgraber merged 9 commits intolxc:mainfrom
bensmrs:colors

Conversation

@bensmrs
Copy link
Copy Markdown
Contributor

@bensmrs bensmrs commented Mar 20, 2026

I believe the changes don’t lead to cognitive overload, while still giving a nice pop to some elements that could benefit from it, helping to navigate through long command descriptions.
This PR also incidentally allows translating command usage sections.

Related-to: #2877
Related-to: #3040

@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 20, 2026

I’ve added a small golangci exception to treat colored printers the same as fmt printers, as they are just wrappers with the same signatures.

@bensmrs bensmrs marked this pull request as draft March 20, 2026 12:04
@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 20, 2026

FormatSection also needs some patching, it seems

bensmrs added 7 commits March 20, 2026 15:11
This incidentally allows translating command usage sections.

Signed-off-by: Benjamin Somers <[email protected]>
@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 20, 2026

Phew, that proved a bit more painful than expected.

@bensmrs bensmrs marked this pull request as ready for review March 20, 2026 15:26
@stgraber stgraber merged commit 7908709 into lxc:main Mar 20, 2026
106 of 108 checks passed
@breml
Copy link
Copy Markdown
Collaborator

breml commented Mar 23, 2026

@bensmrs I am a bit late on this one, but it might be worth mentioning in the docs / README, that colorized output can be disabled using NO_COLOR env, see https://github.com/fatih/color?tab=readme-ov-file#disableenable-color

CC: @stgraber

@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 23, 2026

Ok, will do. I’ll also add a key in the client config to disable it.

@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 23, 2026

I’ve got all the bits working, but I’m wondering a few things, @stgraber.
First, do we have a dedicated place in the docs to mention all the client config parameters? I didn’t find one, so I’m tempted to hide that under the rug for now.
Other thing: we have default-remote at the top level, but list_format, console_type and console_spice_command at the second level. Should I use dashes or underscores for config keys? As my key is top-level, I’m tempted to choose show-colors for now, but we’re not consistent across the codebase.

@stgraber
Copy link
Copy Markdown
Member

I’ve got all the bits working, but I’m wondering a few things, @stgraber. First, do we have a dedicated place in the docs to mention all the client config parameters? I didn’t find one, so I’m tempted to hide that under the rug for now. Other thing: we have default-remote at the top level, but list_format, console_type and console_spice_command at the second level. Should I use dashes or underscores for config keys? As my key is top-level, I’m tempted to choose show-colors for now, but we’re not consistent across the codebase.

Ah yeah, the defaults section is somewhat new. If we had introduced it from the start, we may have made remote be stored under there rather than as its own top-level option.

I think for the color handling, it'd make sense to put that under defaults especially if it's something that we may want to allow overriding some other ways (say NO_COLOR=0 or an eventual --color global option).

And yeah, the CLI configuration doesn't really have any documentation, which is a bit of a problem on its own and something we should probably be addressing ;)
It's mentioned in the context of the remote documentation, but as it stores more than that these days, it probably deserves its own page which the remote doc could then link to instead.

@bensmrs
Copy link
Copy Markdown
Contributor Author

bensmrs commented Mar 23, 2026

Ok, I’ll patch the PR after my evening context switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants