-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
110 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
7 changes: 7 additions & 0 deletions
7
core/shared/src/main/scala/com/monovore/decline/HelpRenderer.scala
This file contains 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,7 @@ | ||
package com.monovore.decline | ||
|
||
sealed trait HelpRenderer extends Product with Serializable | ||
object HelpRenderer { | ||
case object Plain extends HelpRenderer | ||
case object Colors extends HelpRenderer | ||
} |
48 changes: 48 additions & 0 deletions
48
core/shared/src/main/scala/com/monovore/decline/Theme.scala
This file contains 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,48 @@ | ||
package com.monovore.decline | ||
|
||
import cats.Show | ||
import cats.data.NonEmptyList | ||
import cats.syntax.all._ | ||
import com.monovore.decline.HelpRenderer.Plain | ||
import com.monovore.decline.HelpRenderer.Colors | ||
|
||
private[decline] trait Theme { | ||
def sectionHeading(title: String): String = title | ||
def subcommandName(title: String): String = title | ||
def optionName(title: String, loc: Theme.ArgumentRenderingLocation): String = title | ||
def metavar(title: String, loc: Theme.ArgumentRenderingLocation): String = title | ||
def envName(title: String): String = title | ||
def optionPlaceholder(title: String, loc: Theme.ArgumentRenderingLocation): String = title | ||
def optionDescription(value: String): String = value | ||
} | ||
|
||
private[decline] object Theme { | ||
sealed trait ArgumentRenderingLocation extends Product with Serializable | ||
object ArgumentRenderingLocation { | ||
case object InUsage extends ArgumentRenderingLocation | ||
case object InOptions extends ArgumentRenderingLocation | ||
} | ||
def forRenderer(hr: HelpRenderer): Theme = | ||
hr match { | ||
case Plain => PlainTheme | ||
case Colors => ColorTheme | ||
} | ||
} | ||
|
||
private[decline] object PlainTheme extends Theme | ||
|
||
private[decline] object ColorTheme extends Theme { | ||
override def sectionHeading(title: String): String = Console.YELLOW + Console.BOLD + title + Console.RESET | ||
|
||
override def optionName(title: String, loc: Theme.ArgumentRenderingLocation): String = | ||
Console.BOLD + Console.GREEN + title + Console.RESET | ||
|
||
override def metavar(title: String, loc: Theme.ArgumentRenderingLocation): String = | ||
Console.UNDERLINED + title + Console.RESET | ||
|
||
override def envName(title: String): String = | ||
Console.BOLD + Console.GREEN + title + Console.RESET | ||
|
||
override def subcommandName(title: String): String = | ||
Console.BOLD + Console.GREEN + title + Console.RESET | ||
} |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.7.3 | ||
sbt.version=1.9.7 |
This file contains 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