Skip to content

Commit

Permalink
Merge pull request #154 from alexarchambault/remove-cli
Browse files Browse the repository at this point in the history
Remove cli
  • Loading branch information
alexarchambault authored Sep 5, 2022
2 parents 5d2ec0f + 9aa482f commit ebaf1d7
Show file tree
Hide file tree
Showing 19 changed files with 157 additions and 430 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target/
.bsp/
metals.sbt
.vscode/
.bloop/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ val command = AmmoniteFetcher(versions)

val proc: Process = command
.withArgs(Seq(file.getAbsolutePath))
.runBg()
.run()

val retCode: Int = proc.waitFor()
```
Expand Down
41 changes: 7 additions & 34 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import scala.util.Properties

inThisBuild(List(
organization := "io.github.alexarchambault.ammonite",
Expand All @@ -21,12 +22,11 @@ lazy val isAtLeastScala213 = Def.setting {

val scala213 = "2.13.8"
val scala212 = "2.12.16"
val scala211 = "2.11.12"

lazy val shared = Def.settings(
sonatypeProfileName := "io.github.alexarchambault",
scalaVersion := scala213,
crossScalaVersions := Seq(scala213, scala212, scala211),
crossScalaVersions := Seq(scala213, scala212),
libraryDependencies ++= {
if (isAtLeastScala213.value) Nil
else Seq(compilerPlugin(Deps.macroParadise))
Expand All @@ -47,10 +47,13 @@ lazy val core = project
Deps.coursierInterface,
Deps.coursierLauncher,
Deps.dataClass % Provided,
Deps.svm % Provided,
Deps.utest.value % Test
Deps.osLib % Test,
Deps.utest % Test
),
testFrameworks += new TestFramework("utest.runner.Framework"),
mimaPreviousArtifacts := {
mimaPreviousArtifacts.value.filter(!_.revision.startsWith("0.3."))
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
Seq(
Expand All @@ -61,36 +64,6 @@ lazy val core = project
}
)

lazy val cli = project
.dependsOn(core)
// .enablePlugins(GraalVMNativeImagePlugin)
.enablePlugins(PackPlugin)
.disablePlugins(MimaPlugin)
.settings(
name := "ammonite-runner-cli",
shared,
crossScalaVersions := crossScalaVersions.value.filter(!_.startsWith("2.11.")),
libraryDependencies ++= Seq(
Deps.caseApp,
Deps.utest.value % Test
),
testFrameworks += new TestFramework("utest.runner.Framework"),
Test / fork := true,
Test / javaOptions += {
val isWindows = System.getProperty("os.name")
.toLowerCase(java.util.Locale.ROOT)
.contains("windows")
val ext = if (isWindows) ".bat" else ""
val launcher = (Compile / pack)
.value
.getAbsoluteFile
./("bin/amm-runner" + ext)
.toString
s"-Dammrunner.launcher=$launcher"
},
// graalVMNativeImageOptions += "--no-server"
)

shared
publish / skip := true
disablePlugins(MimaPlugin)
Expand Down

This file was deleted.

18 changes: 0 additions & 18 deletions cli/src/main/resources/META-INF/native-image/reflect-config.json

This file was deleted.

60 changes: 0 additions & 60 deletions cli/src/main/scala/ammrunner/cli/AmmRunner.scala

This file was deleted.

47 changes: 0 additions & 47 deletions cli/src/main/scala/ammrunner/cli/Options.scala

This file was deleted.

89 changes: 0 additions & 89 deletions cli/src/test/scala/ammrunner/cli/AmmRunnerTests.scala

This file was deleted.

32 changes: 0 additions & 32 deletions cli/src/test/scala/ammrunner/cli/TestUtil.scala

This file was deleted.

41 changes: 41 additions & 0 deletions core/src/main/scala/ammrunner/AmmRunner.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ammrunner.cli

import java.io.File

import ammrunner.{AmmoniteFetcher, Command, Versions, VersionsOption}

object AmmRunner {

def command(
ammVersion: Option[String],
scalaVersion: Option[String],
args: Seq[String]
): Command = {

val scriptPathOpt = args
.iterator
.filter(!_.startsWith("-"))
.filter(_.endsWith(".sc"))
.map(new File(_))
.filter(_.isFile)
.toStream
.headOption

val versionsOpt = VersionsOption(ammVersion, scalaVersion)
val versions = scriptPathOpt match {
case None =>
versionsOpt.getOrElse(Versions.default())

case Some(script) =>
versionsOpt
.orElse(VersionsOption.fromScript(script))
.getOrElse(Versions.default())
}
val command = AmmoniteFetcher(versions).command() match {
case Left(e) => throw new Exception("Error getting Ammonite class path", e)
case Right(cmd) => cmd
}

command.withArgs(args)
}
}
Loading

0 comments on commit ebaf1d7

Please sign in to comment.