Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opening this as a draft pull request because the current design makes this very awkward.
Paging @robdockins and @kquick who might have ideas/concerns.
Problem: The
--no-colors
flag I added does not remove colors for--help
and--version
. This was known, it was just much harder to support it for those than the rest.Reason: Those options are parsed "early", before Crux parses the rest of the options, to terminate the program early. As a result, they are executed before the
--no-colors
flag is even read.Solution: One can make the
--no-colors
flag be parsed early, so that the help and version commands can use colors appropriately.However, this creates a cascade of other annoyances. First, to pass the options to the logger, we need to either:
CruxOptions ColorOptions OtherOptions
,CruxOptions
all those options that are related to output (that have sensible default values), so that we can pass thoseOutputOptions
to the logger.Of course, any attempt to de-flatten the structure of
CruxOptions
makes it somewhat annoying to perform nested updates without lenses. I'm not sure what's everyone's feeling on the use of lenses, and the use of Template Haskell to generate them. In this draft, I'm using lenses, but rather than bringingTemplateHaskell
, which can make things slower, I just hand-write one lens.This brings up the question of whether we should lensify the whole thing.
Because I chose a structure:
there is still a very awkward setting of
defaultColorOptions
incruxOptions :: Config CruxOptions
, because it has to return aCruxOptions
but cannot know the color options.If we were to go an alternative route of:
we would get rid of this awkwardness, but manipulating this without lenses would also be unpleasant.
TL;DR:
There are four set of options:
--help
and--version
while respecting--no-colors
, we need to parse (1.) and (2.) early.--help
and--version
runs.