-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HelpProvider renders some formatting markup even with NO_COLOR #1583
Comments
Currently, running `--help` with `NO_COLOR` set, results in formatting still being applied via markup to the options and default values. This complements the previous fix for spectreconsole#211 for that scenario and is related to spectreconsole#1408. Fixes spectreconsole#1583
I got a draft PR just to explore what the changes might be. Feel free to suggest alternatives. All existing tests pass fine, but I could not find unit tests specifically exercising the HelpProvider itself, to add a failing test and make it pass :). But the new output after the PR looks as I expected, without any formatting whatesoever:
|
|
To automate output and get rid of ANSI sequences, you should disable ANSI completely using the console profile and add a switch in your application. NO_COLOR is not the way to go here. You can also use a console recorder (https://spectreconsole.net/api/spectre.console/recorder/) to record the output. |
Do you think there's an opportunity to provide something like this at least for the restricted use case of rendering text-only versions of help for the purposes of self-updating static docs for a tool? |
Got a workaround for now in my app: var app = new CommandApp();
// ...
app.Configure(config =>
{
if (Environment.GetEnvironmentVariables().Contains("NO_COLOR") &&
config.Settings.HelpProviderStyles?.Options is { } options)
options.DefaultValue = Style.Plain;
}); |
Hello @kzu, FYI. there is a unit test demonstrating a completely unstyled help output, see: spectre.console/src/Tests/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Help.cs Line 413 in 42fd801
That results in
I would probably recommend you follow this approach instead, which is very similar to yours, but would prevent any future issues with styling being added to other sections in the help writer output in future releases (nb. no plans to do so, just saying). |
Also improve IDE speed by not regenerating help.md in design-time builds. See also spectreconsole/spectre.console#1583 (comment)
Also improve IDE speed by not regenerating help.md in design-time builds. See also spectreconsole/spectre.console#1583 (comment)
Also improve IDE speed by not regenerating help.md in design-time builds. See also spectreconsole/spectre.console#1583 (comment)
Also improve IDE speed by not regenerating help.md in design-time builds. See also spectreconsole/spectre.console#1583 (comment)
@FrankRay78 that didn't work. It seems it's being re-set by someone else. The default values are bold even though I set the help styles to null: |
Thanks for testing @kzu, I'll bump this up my list of things to fix. |
To Reproduce
Raw output:
Expected behavior
Renders text only, with no bold or any other styles applied.
Screenshots
Default values have bold style applied:
The importance of the issue is that it prevents having an automated way to self-document a CLI tool via the package readme, automatically updated after compile with up-to-date usage info, as shown in https://www.cazzulino.com/auto-doc-cli.html
The text was updated successfully, but these errors were encountered: