-
Notifications
You must be signed in to change notification settings - Fork 75
Render colours in help #539
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9e50b30
WIP: render colours in help
keynmol e8ccc87
Space out arguments a little bit
keynmol 7bfe87a
Refactor help to be rendered from structured information
keynmol 1020450
Merge branch 'main' into colors
keynmol 8a7f862
Make autoColors a method, remove double newlines
keynmol 1e13d57
Merge branch 'main' into colors
keynmol b3976dc
WIP
keynmol 96c00ed
Attempt to restore bincompat
keynmol c781fd5
Bump deprecation version
keynmol ae9eeba
make lazy val private
keynmol 475330a
Add RenderOptions for fine grained control of output
keynmol a00d099
Merge RenderOptions into HelpFormat
keynmol d8658fb
Render usages on single line
keynmol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/shared/src/main/scala/com/monovore/decline/HelpFormat.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.monovore.decline | ||
|
|
||
| sealed abstract class HelpFormat extends Product with Serializable { | ||
|
keynmol marked this conversation as resolved.
Outdated
|
||
| def colorsEnabled: Boolean | ||
| } | ||
| object HelpFormat { | ||
| case object Plain extends HelpFormat { | ||
| override def colorsEnabled: Boolean = false | ||
| } | ||
| case object Colors extends HelpFormat { | ||
| override def colorsEnabled: Boolean = true | ||
| } | ||
| case class AutoColors(env: Map[String, String] = sys.env) extends HelpFormat { | ||
|
keynmol marked this conversation as resolved.
Outdated
|
||
| /* | ||
|
|
||
| http://no-color.org/ | ||
|
|
||
| "Command-line software which adds ANSI color to its output by default should | ||
| check for a NO_COLOR environment variable that, when present and not an empty | ||
| string (regardless of its value), prevents the addition of ANSI color." | ||
|
|
||
| */ | ||
|
|
||
| override def colorsEnabled: Boolean = env.get("NO_COLOR").exists(_.nonEmpty) | ||
|
|
||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! This seems like something with this shape could eventually be cleaned up and made public for some of the fancier help-rendering ideas folks have had (HTML generation, etc.) but leaving it private for now seems like the right call.