Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: read fore/background colors on first access
Caching the colors in OutputOption makes the order of options important. For example, if you're using WithUnsafe _after_ WithColorCache, the colors wouldn't respect the `unsafe` option since the colors get cached _during_ the execution of WithColorCache option. Another example, is the use of a custom environ using the WithEnvironment option. If WithEnvironment comes _before_ WithColorCache, reading the terminal colors won't respect the values in the environment. Instead, don't read the colors in WithColorCache and make the user opt-in if they want to cache the colors right after creating a new output using ForegroundColor and BackgroundColor. ```go // To cache the colors after creating an output output := NewOutput(os.Stderr) _ = output.ForegroundColor() _ = output.BackgroundColor() ```
- Loading branch information