-
Notifications
You must be signed in to change notification settings - Fork 71
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
WIP: render colours in help #539
base: main
Are you sure you want to change the base?
Changes from 4 commits
9e50b30
e8ccc87
7bfe87a
1020450
8a7f862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be tempted to define this on the |
||
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat - was not aware of this! This could be a method returning a format instead of a format of its own... and I'd prefer to not include |
||
/* | ||
|
||
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) | ||
|
||
} | ||
} |
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.