Skip to content

Commit

Permalink
Improve style disable when NO_COLOR
Browse files Browse the repository at this point in the history
Also improve IDE speed by not regenerating help.md in design-time builds.

See also spectreconsole/spectre.console#1583 (comment)
  • Loading branch information
kzu committed Sep 2, 2024
1 parent e281784 commit fb71e1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/dotnet-trx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
// Causes -v|--version to be added to help
config.SetApplicationVersion(ThisAssembly.Project.Version);
if (Environment.GetEnvironmentVariables().Contains("NO_COLOR") &&
config.Settings.HelpProviderStyles?.Options is { } options)
options.DefaultValue = Style.Plain;
if (Environment.GetEnvironmentVariables().Contains("NO_COLOR"))
config.Settings.HelpProviderStyles = null;
});

if (args.Contains("--version"))
Expand Down
11 changes: 6 additions & 5 deletions src/dotnet-trx/dotnet-trx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
<ProjectProperty Include="PackageProjectUrl" />
</ItemGroup>

<Target Name="RenderHelp" AfterTargets="Build">
<WriteLinesToFile Lines="```shell" Overwrite="true" File="help.md" />
<Exec Command="dotnet run --no-build -- --help &gt;&gt; help.md" EnvironmentVariables="NO_COLOR=true" />
<WriteLinesToFile Lines="```" Overwrite="false" File="help.md" />
</Target>
<Target Name="RenderHelp" AfterTargets="Build" Condition="$(DesignTimeBuild) != 'true'" >
<WriteLinesToFile Lines="```shell" Overwrite="true" File="help.md" />
<Exec Command="dotnet run --no-build -- --help &gt;&gt; help.md"
EnvironmentVariables="NO_COLOR=true" />
<WriteLinesToFile Lines="```" Overwrite="false" File="help.md" />
</Target>

</Project>

0 comments on commit fb71e1a

Please sign in to comment.