Skip to content

Commit

Permalink
A range of cli improvements
Browse files Browse the repository at this point in the history
* write --help
* error on stale semanticdb
  • Loading branch information
olafurpg committed May 29, 2018
1 parent 77f1cfa commit 7811980
Show file tree
Hide file tree
Showing 23 changed files with 385 additions and 277 deletions.
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ val cli = MultiScalaProject(
"cli",
_.settings(
isFullCrossVersion,
mainClass in assembly := Some("scalafix.cli.Cli"),
mainClass in assembly := Some("scalafix.v1.Main"),
assemblyJarName in assembly := "scalafix.jar",
libraryDependencies ++= Seq(
"com.github.alexarchambault" %% "case-app" % "1.2.0",
"org.typelevel" %% "paiges-core" % "0.2.0",
"com.martiansoftware" % "nailgun-server" % "0.9.1",
jgit,
"ch.qos.logback" % "logback-classic" % "1.2.3",
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._

object Dependencies {
val scalametaV = "4.0.0-M1"
val metaconfigV = "0.7.2"
val metaconfigV = "0.8.3"
def dotty = "0.1.1-bin-20170530-f8f52cc-NIGHTLY"
def scala210 = "2.10.6"
// NOTE(olafur) downgraded from 2.11.12 and 2.12.4 because of non-reproducible error
Expand Down
6 changes: 3 additions & 3 deletions scalafix-cli/src/main/scala/scalafix/cli/Cli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ object ScalafixRuleNames {
CliRunner.fromOptions(options) match {
case Ok(runner) => RunScalafix(runner)
case NotOk(err) =>
PrintAndExit(err.toString(), ExitStatus.InvalidCommandLineOption)
PrintAndExit(err.toString(), ExitStatus.CommandLineError)
}
def main(args: Array[String]): Unit = {
val exit = runMain(args.to[Seq], CommonOptions())
Expand All @@ -214,7 +214,7 @@ object ScalafixRuleNames {
import CliCommand._
OptionsParser.withHelp.detailedParse(args) match {
case Left(err) =>
PrintAndExit(err, ExitStatus.InvalidCommandLineOption)
PrintAndExit(err, ExitStatus.CommandLineError)
case Right((WithHelp(_, help @ true, _), _, _)) =>
PrintAndExit(helpMessage, ExitStatus.Ok)
case Right((WithHelp(usage @ true, _, _), _, _)) =>
Expand Down Expand Up @@ -260,7 +260,7 @@ object ScalafixRuleNames {
// This one accummulates a lot of garbage, scalameta needs to get rid of it.
PlatformTokenizerCache.megaCache.clear()
if (commonOptions.cliArg.hasErrors) {
ExitStatus.merge(ExitStatus.InvalidCommandLineOption, result)
ExitStatus.merge(ExitStatus.CommandLineError, result)
} else {
result
}
Expand Down
4 changes: 2 additions & 2 deletions scalafix-cli/src/main/scala/scalafix/cli/CliRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ sealed abstract case class CliRunner(
Patch.unifiedDiff(input.semanticFile.get, input.original)
common.err.println(diff)
}
ExitStatus.StaleSemanticDB
ExitStatus.StaleSemanticdbError
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ sealed abstract case class CliRunner(
)
)
common.out.println(diff)
ExitStatus.TestFailed
ExitStatus.TestError
}
case WriteMode.WriteFile =>
val (fixed, messages) = rule.applyAndLint(ctx)
Expand Down
8 changes: 4 additions & 4 deletions scalafix-cli/src/main/scala/scalafix/cli/ExitStatus.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ object ExitStatus {
UnexpectedError,
ParseError,
ScalafixError,
InvalidCommandLineOption,
MissingSemanticDB,
StaleSemanticDB,
TestFailed,
CommandLineError,
MissingSemanticdbError,
StaleSemanticdbError,
TestError,
LinterError,
NoFilesError
: ExitStatus = generateExitStatus
Expand Down
84 changes: 0 additions & 84 deletions scalafix-cli/src/main/scala/scalafix/internal/cli/CliParser.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ case class ScalafixOptions(
def parallel: Boolean = !noParallel
def classpathRoots: List[AbsolutePath] =
classpathAutoRoots.fold(List(common.workingPath))(cp =>
Classpath(cp).shallow)
Classpath(cp).entries)
def projectIdPrefix: String = projectId.fold("")(id => s"[$id] ")
lazy val diagnostic: ScalafixReporter =
ScalafixReporter.default.copy(
Expand Down
Loading

0 comments on commit 7811980

Please sign in to comment.