Skip to content

Commit

Permalink
Remove showVersion setting and fix welcome task
Browse files Browse the repository at this point in the history
  • Loading branch information
reibitto committed Aug 28, 2020
1 parent 65b2f26 commit a9d50dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 9 additions & 3 deletions README.md
Expand Up @@ -19,9 +19,13 @@ aliases are optional, but can be useful for particularly long commands.
Add the following to `project/plugins.sbt`:

```scala
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.1.1")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.0")
```

## Commands

You can type `welcome` to re-print the welcome message (rather than reloading the project).

## Configuration

An example configuration:
Expand All @@ -46,9 +50,11 @@ usefulTasks := Seq(

```

To disable showing the version number you can add:
You can embed any other information in the logo, such as the project version with normal Scala string interpolation like:

`showVersion := false`
```scala
logo := s"Some Logo ${version.value}"
```

You can also change the default colors like so:

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
@@ -1,7 +1,7 @@
lazy val root = (project in file(".")).
settings(
name := "sbt-welcome",
version := "0.1.2-SNAPSHOT",
version := "0.2.1-SNAPSHOT",
organization := "com.github.reibitto",
scalaVersion := "2.12.10",
sbtPlugin := true
Expand Down
12 changes: 4 additions & 8 deletions src/main/scala/sbtwelcome/WelcomePlugin.scala
Expand Up @@ -9,7 +9,6 @@ object WelcomePlugin extends AutoPlugin {
object autoImport {
val logo = settingKey[String]("logo")
val usefulTasks = settingKey[Seq[UsefulTask]]("usefulTasks")
val showVersion = settingKey[Boolean]("showVersion")
val logoColor = settingKey[String]("logoColor")
val aliasColor = settingKey[String]("aliasColor")
val commandColor = settingKey[String]("commandColor")
Expand All @@ -33,15 +32,14 @@ object WelcomePlugin extends AutoPlugin {
| | |
| |_| """.stripMargin,
usefulTasks := Nil,
welcome := welcomeTask.value,
showVersion := true,
welcome in LocalRootProject := welcomeTask.value,
logoColor := SConsole.GREEN,
aliasColor := SConsole.MAGENTA,
commandColor := SConsole.CYAN,
onLoadMessage := {
// Need to color each line because SBT resets the color for each line when printing `[info]`
val renderedLogo = logo.value.linesIterator.map { line =>
s"${logoColor.value}${line}"
s"${logoColor.value}$line"
}.mkString("\n")

val renderedCommands = usefulTasks.value.map { u =>
Expand All @@ -60,9 +58,7 @@ object WelcomePlugin extends AutoPlugin {
s"$bulletPoint ${commandColor.value}${u.command}${SConsole.RESET}${description}"
}.mkString("\n")

val versionString = if(showVersion.value) s" ${version.value}" else ""

s"$renderedLogo$versionString${SConsole.RESET}\nUseful sbt tasks:\n${renderedCommands}"
s"$renderedLogo${SConsole.RESET}\nUseful sbt tasks:\n$renderedCommands"
},
onLoad in GlobalScope += { (initialState: State) =>
usefulTasks.value.foldLeft(initialState) {
Expand All @@ -82,7 +78,7 @@ object WelcomePlugin extends AutoPlugin {

lazy val welcomeTask =
Def.task {
println(onLoadMessage.value)
println((onLoadMessage in LocalRootProject).value)
}

}
Expand Down

0 comments on commit a9d50dd

Please sign in to comment.