Skip to content

Commit

Permalink
Merge pull request #592 from scalacenter/topic/homebrew-logs
Browse files Browse the repository at this point in the history
Add release notes for v1.0.0 and log plist service
  • Loading branch information
jvican authored Jul 18, 2018
2 parents 46c0fa2 + 25a50f1 commit b4eeba0
Show file tree
Hide file tree
Showing 9 changed files with 595 additions and 269 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ Bloop's documentation lives in [our website](https://scalacenter.github.io/bloop
documentation](https://scalacenter.github.io/bloop/docs/developer-documentation/)
to learn how to hack on the project, run our community build, improve
documentation, etc.

### Maintainers

The people that can merge pull requests are:

1. [Paweł Bartkiewicz](https://github.com/tues)
1. [Ruben Berenguel](https://github.com/Duhemm)
1. [Martin Duhem](https://github.com/Duhemm)
1. [Jorge Vicente Cantero](https://github.com/jvican)
1. You? :smile: Follow our [CONTRIBUTING guide](https://scalacenter.github.io/bloop/docs/developer-documentation/).

10 changes: 6 additions & 4 deletions frontend/src/main/scala/bloop/cli/CliOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import caseapp.{ExtraName, HelpMessage, Recurse, ValueDescription}

case class CliOptions(
@ExtraName("c")
@HelpMessage("File path to the bloop config directory.")
@HelpMessage(
"File path to the bloop config directory, defaults to `.bloop` in the current working directory.")
@ValueDescription(".bloop")
configDir: Option[Path] = None,
@ExtraName("v")
@HelpMessage("If set, print the about section at the beginning of the execution.")
@HelpMessage(
"If set, print the about section at the beginning of the execution. Defaults to false.")
version: Boolean = false,
@HelpMessage("If set, print out debugging information to stderr.")
@HelpMessage("If set, print out debugging information to stderr. Defaults to false.")
verbose: Boolean = false,
@HelpMessage("If set, do not color output.")
@HelpMessage("If set, do not color output. Defaults to false.")
noColor: Boolean = false,
@Recurse common: CommonOptions = CommonOptions.default,
)
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/main/scala/bloop/cli/CliParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ object CliParsers {
ArgParser.instance[InputStream]("stdin")(_ => Right(System.in))
implicit val printStreamRead: ArgParser[PrintStream] =
ArgParser.instance[PrintStream]("stdout")(_ => Right(System.out))
implicit val pathParser: ArgParser[Path] = ArgParser.instance("A filepath parser") {
implicit val pathParser: ArgParser[Path] = ArgParser.instance("path") {
case supposedPath: String =>
val toPath = Try(Paths.get(supposedPath)).toEither
toPath.left.map(t => s"The provided path ${supposedPath} is not valid: '${t.getMessage()}'.")
}

implicit val completionFormatRead: ArgParser[completion.Format] = {
ArgParser.instance[completion.Format]("format") {
ArgParser.instance[completion.Format]("\"bash\" | \"zsh\"") {
case "bash" => Right(completion.BashFormat)
case "zsh" => Right(completion.ZshFormat)
case w00t => Left(s"Unrecognized format: $w00t")
}
}

implicit val optimizerConfigRead: ArgParser[OptimizerConfig] = {
ArgParser.instance[OptimizerConfig]("optimize") {
ArgParser.instance[OptimizerConfig]("\"debug\" | \"release\"") {
case "debug" => Right(OptimizerConfig.Debug)
case "release" => Right(OptimizerConfig.Release)
case w00t => Left(s"Unrecognized optimizer config: $w00t")
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/main/scala/bloop/cli/Commands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.nio.file.Path
import bloop.cli.CliParsers.CommandsMessages
import bloop.engine.ExecutionContext
import bloop.io.AbsolutePath
import caseapp.{ArgsName, CommandName, ExtraName, HelpMessage, Hidden, Recurse}
import caseapp.{CommandName, ExtraName, HelpMessage, Recurse}
import caseapp.core.CommandMessages

object Commands {
Expand Down Expand Up @@ -56,15 +56,13 @@ object Commands {
) extends RawCommand

case class Projects(
@ExtraName("dot")
@HelpMessage("Print out a dot graph you can pipe into `dot`. By default, false.")
dotGraph: Boolean = false,
@Recurse cliOptions: CliOptions = CliOptions.default
) extends RawCommand

case class Configure(
@ExtraName("parallelism")
@HelpMessage("Set the number of threads used for parallel compilation and test execution.")
@HelpMessage("Set the number of threads used to compile and test all projects.")
threads: Int = ExecutionContext.executor.getCorePoolSize,
@Recurse cliOptions: CliOptions = CliOptions.default
) extends RawCommand
Expand All @@ -81,18 +79,14 @@ object Commands {

@CommandName("bsp")
case class Bsp(
@ExtraName("p")
@HelpMessage("The connection protocol for the bsp server. By default, local.")
protocol: BspProtocol = BspProtocol.Local,
@ExtraName("h")
@HelpMessage("The server host for the bsp server (TCP only).")
host: String = "127.0.0.1",
@HelpMessage("The port for the bsp server (TCP only).")
port: Int = 5101,
@ExtraName("s")
@HelpMessage("A path to a socket file to communicate through Unix sockets (local only).")
socket: Option[Path] = None,
@ExtraName("pn")
@HelpMessage(
"A path to a new existing socket file to communicate through Unix sockets (local only).")
pipeName: Option[String] = None,
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/main/scala/bloop/cli/CommonOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ case class CommonOptions(
@Hidden err: PrintStream = System.err,
@Hidden ngout: PrintStream = System.out,
@Hidden ngerr: PrintStream = System.err,
@Hidden env: CommonOptions.PrettyProperties = CommonOptions.currentEnv,
threads: Int = ExecutionContext.nCPUs
@Hidden env: CommonOptions.PrettyProperties = CommonOptions.currentEnv
) {
def workingPath: AbsolutePath = AbsolutePath(workingDirectory)
}
Expand Down
138 changes: 138 additions & 0 deletions frontend/src/main/scala/bloop/util/CommandsDocGenerator.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package bloop.util

import bloop.Cli
import bloop.cli.{CliParsers, Commands, CommonOptions}
import bloop.engine.Run
import caseapp.{Name, ValueDescription}
import caseapp.core.{Arg, Messages, NameOps, ValueDescriptionOps}

object CommandsDocGenerator {
def main(args: Array[String]): Unit = {
def generateHTML(commandExamples: Map[String, Seq[String]]): Seq[String] = {
CliParsers.CommandsMessages.messages.map {
case (commandName, messages) =>
val examples = commandExamples.getOrElse(commandName, Nil).reverse.map { example =>
s" * <samp>$example</samp>"
}

val argsOption = messages.argsNameOption.map(" <" + _ + ">").mkString
val progName = "bloop"
val b = new StringBuilder
b ++= Messages.NL
b ++= s"## `$progName $commandName$argsOption`"
b ++= Messages.NL
b ++= Messages.NL
b ++= "### Usage"
b ++= Messages.NL
b ++= Messages.NL
b ++= s"<dl>"
b ++= Messages.NL
b ++= optionsMessage(messages.args)
b ++= Messages.NL
b ++= s"</dl>"
b ++= Messages.NL
if (examples.nonEmpty) {
b ++= Messages.NL
b ++= s"### Examples ${Messages.NL}"
b ++= Messages.NL
b ++= examples.mkString(Messages.NL)
}
b.result()
}
}

parseExamples match {
case Left(msg) => println(s"Error: $msg")
case Right(commandExamples) =>
println(generateHTML(commandExamples).mkString(Messages.NL))
}
}

def optionsMessage(args: Seq[Arg]): String = {
val options = args.collect {
case arg if !arg.noHelp =>
val names = (Name(arg.name) +: arg.extraNames).distinct
val valueDescription =
arg.valueDescription.orElse(if (!arg.isFlag) Some(ValueDescription("value")) else None)

val message = arg.helpMessage.map(_.message).getOrElse("")
val cmdNames = names.map("<code>" + _.option + "</code>").mkString(" or ")
val usage = s"${Messages.WW}$cmdNames ${valueDescription.map(_.message).mkString}"
val description =
if (message.isEmpty) message
else s"${Messages.NL} <dd><p>${message}</p></dd>"
s" <dt>$cmdNames (type: <code>${arg.hintDescription}</code>)</dt>$description"
}

options.mkString(Messages.NL)
}

private val ExampleProjectName: String = "foobar"
private val ExampleMainClass: String = "com.acme.Main"
private final val CommandExamples = {
val tmp = java.nio.file.Files.createTempDirectory("tmp")
List(
"bloop projects",
"bloop projects --dot-graph",
s"bloop clean $ExampleProjectName",
s"bloop clean $ExampleProjectName --propagate",
s"bloop bsp --protocol local --socket ${tmp.resolve("socket").toString} --pipe-name windows-name-pipe",
"bloop bsp --protocol tcp --host 127.0.0.1 --port 5101",
s"bloop compile $ExampleProjectName",
s"bloop compile $ExampleProjectName -w",
s"bloop compile $ExampleProjectName --reporter bloop",
s"bloop compile $ExampleProjectName --reporter scalac",
s"bloop test $ExampleProjectName",
s"bloop test $ExampleProjectName -w",
s"bloop test $ExampleProjectName --propagate",
s"bloop test $ExampleProjectName --propagate -w",
s"bloop test $ExampleProjectName --only com.acme.StringSpecification",
s"bloop console $ExampleProjectName",
s"bloop console $ExampleProjectName --exclude-root",
s"bloop run $ExampleProjectName",
s"bloop run $ExampleProjectName -m $ExampleMainClass -- arg1 arg2",
s"bloop run $ExampleProjectName -O debug -- arg1",
s"bloop run $ExampleProjectName -m $ExampleMainClass -O release -w",
s"bloop link $ExampleProjectName",
s"bloop link $ExampleProjectName --main $ExampleMainClass",
s"bloop link $ExampleProjectName -O debug -w",
s"bloop link $ExampleProjectName -O release -w",
s"bloop link $ExampleProjectName --main $ExampleMainClass -w",
)
}

private def commandName(cmd: Commands.Command): Option[String] = {
cmd match {
case _: Commands.About => Some("about")
case _: Commands.Projects => Some("projects")
case _: Commands.Clean => Some("clean")
case _: Commands.Bsp => Some("bsp")
case _: Commands.Compile => Some("compile")
case _: Commands.Test => Some("test")
case _: Commands.Console => Some("console")
case _: Commands.Run => Some("run")
case _: Commands.Link => Some("link")
case _ => None
}
}

case class Example(projectName: String, examples: List[String])
def parseExamples: Either[String, Map[String, List[String]]] = {
val parsed = CommandExamples.foldLeft[Either[String, List[Example]]](Right(Nil)) {
case (l @ Left(_), _) => l
case (Right(prevExamples), example) =>
Cli.parse(example.split(" ").tail, CommonOptions.default) match {
case Run(cmd: Commands.Command, _) =>
commandName(cmd) match {
case Some(name) =>
Right(Example(name, List(example)) :: prevExamples)
case None => Right(prevExamples)
}

case a => Left(s"Example $example yielded unrecognized action $a")
}
}

parsed.map(_.groupBy(_.projectName).mapValues(_.flatMap(_.examples)))
}
}
Loading

0 comments on commit b4eeba0

Please sign in to comment.