Skip to content

Commit

Permalink
Merge command, hugo, commands modules
Browse files Browse the repository at this point in the history
  • Loading branch information
reidspencer committed Nov 26, 2024
1 parent 0d69c79 commit 2bf4ce4
Show file tree
Hide file tree
Showing 120 changed files with 157 additions and 242 deletions.
69 changes: 12 additions & 57 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ lazy val riddl: Project = Root("riddl", startYr = startYear /*, license = "Apach
diagramsJS,
riddlLib,
riddlLibJS,
command,
hugo,
commands,
riddlc,
docsite,
Expand Down Expand Up @@ -200,7 +198,7 @@ lazy val diagrams_cp: CrossProject = CrossModule("diagrams", "riddl-diagrams")(J
val diagrams = diagrams_cp.jvm
val diagramsJS = diagrams_cp.js

lazy val riddlLib_cp: CrossProject = CrossModule("riddlLib", "riddl-lib")(JS, JVM)
lazy val riddlLib_cp: CrossProject = CrossModule("riddlLib", "riddl-lib")(JVM, JS)
.dependsOn(cpDep(utils_cp), cpDep(language_cp), cpDep(passes_cp), cpDep(diagrams_cp))
.configure(With.scala3, With.publishing)
.settings(
Expand All @@ -209,71 +207,30 @@ lazy val riddlLib_cp: CrossProject = CrossModule("riddlLib", "riddl-lib")(JS, JV
val riddlLib = riddlLib_cp.jvm
val riddlLibJS = riddlLib_cp.js

val Command = config("command")
lazy val command = Module("command", "riddl-command")
.configure(With.typical, With.coverage(30), With.MiMa("0.52.1"))
.configure(With.publishing, With.headerLicense("Apache-2.0"))
.settings(
coverageExcludedPackages := "<empty>;$anon",
description := "Command infrastructure needed to define a command",
Test / parallelExecution := false,
libraryDependencies ++= Seq(
Dep.scopt,
Dep.pureconfig,
"org.scala-js" %% "scalajs-stubs" % "1.1.0" % "provided"
) ++ Dep.testing
)
.dependsOn(pDep(utils), pDep(language), passes)

def testDep(project: Project): ClasspathDependency = project % "compile->compile;compile->test;test->test"

val Hugo = config("hugo")
lazy val hugo = Module("hugo", "riddl-hugo")
.configure(With.typical, With.publishing, With.headerLicense("Apache-2.0"))
.configure(With.coverage(65))
.configure(With.MiMa("0.52.1"))
.settings(
coverageExcludedFiles := """<empty>;$anon""",
scalacOptions += "-explain-cyclic",
description := "Implementation for the RIDDL hugo command, a website generator",
libraryDependencies ++= Dep.testing ++ Seq(
"org.scala-js" %% "scalajs-stubs" % "1.1.0" % "provided"
)
)
.dependsOn(utils, pDep(language), pDep(passes), diagrams, pDep(command))

val Commands = config("commands")
lazy val commands: Project = Module("commands", "riddl-commands")
lazy val commands_cp: CrossProject = CrossModule("commands", "riddl-commands")(JVM)
.dependsOn(cpDep(utils_cp), cpDep(language_cp), cpDep(passes_cp), cpDep(diagrams_cp))
.configure(With.typical, With.publishing, With.headerLicense("Apache-2.0"))
.configure(With.coverage(50))
.configure(With.MiMa("0.52.1"))
.settings(
coverageExcludedFiles := """<empty>;$anon""",
scalacOptions ++= Seq("-explain", "--explain-types", "--explain-cyclic"),
description := "RIDDL Command Infrastructure and basic command definitions",
description := "RIDDL Command Infrastructure and command definitions",
libraryDependencies ++= Seq(Dep.scopt, Dep.pureconfig) ++ Dep.testing ++ Seq(
"org.scala-js" %% "scalajs-stubs" % "1.1.0" % "provided"
)
)
.dependsOn(
pDep(utils),
pDep(language),
pDep(passes),
command,
hugo
.jvmConfigure(With.coverage(50))
.jvmConfigure(With.MiMa("0.52.1"))
.jvmSettings(
coverageExcludedFiles := """<empty>;$anon"""
)
val commands: Project = commands_cp.jvm

val Riddlc = config("riddlc")
lazy val riddlc: Project = Program("riddlc", "riddlc")
.configure(With.typical, With.publishing, With.headerLicense("Apache-2.0"))
.configure(With.coverage(50.0))
.configure(With.noMiMa)
.dependsOn(
utils,
language,
testDep(passes),
testDep(commands)
)
.dependsOn(pDep(utils), pDep(language), pDep(passes), pDep(commands))
.settings(
coverageExcludedFiles := """<empty>;$anon""",
description := "The `riddlc` compiler and tests, the only executable in RIDDL",
Expand All @@ -295,8 +252,6 @@ lazy val docProjects = List(
(language, Language),
(passes, Passes),
(diagrams, Diagrams),
(command, Command),
(hugo, Hugo),
(commands, Commands),
(riddlc, Riddlc)
)
Expand All @@ -312,7 +267,7 @@ lazy val docsite = DocSite(
dirName = "doc",
apiOutput = file("src") / "main" / "hugo" / "static" / "apidoc",
baseURL = Some("https://riddl.tech/apidoc"),
inclusions = Seq(utils, language, passes, diagrams, command, hugo, commands),
inclusions = Seq(utils, language, passes, diagrams, commands),
logoPath = Some("doc/src/main/hugo/static/images/RIDDL-Logo-128x128.png")
)
.settings(
Expand All @@ -321,7 +276,7 @@ lazy val docsite = DocSite(
libraryDependencies ++= Dep.testing
)
.configure(With.noMiMa)
.dependsOn(utils, language, passes, diagrams, command, hugo, commands)
.dependsOn(utils, language, passes, diagrams, commands)

lazy val plugin = Plugin("sbt-riddl")
.configure(With.build_info, With.scala2, With.noMiMa, With.publishing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.utils.PlatformContext
import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.language.{At, Messages}
import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}
import com.ossuminc.riddl.language.Messages.*
import com.ossuminc.riddl.language.{At, Messages}
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}
import com.ossuminc.riddl.utils.{CommonOptions, PlatformContext}

import pureconfig.error.ConfigReaderFailures
import pureconfig.{ConfigCursor, ConfigObjectCursor, ConfigReader, ConfigSource}

import java.nio.file.Path
import scala.util.control.NonFatal
import scala.jdk.CollectionConverters.CollectionHasAsScala
import scala.util.control.NonFatal

object Commands:

Expand Down Expand Up @@ -212,19 +211,19 @@ object Commands:

def runMain(args: Array[String])(using pc: PlatformContext): Int =
try

val (common, remaining) = CommonOptionsHelper.parseCommonOptions(args)
common match
case Some(commonOptions) =>
pc.withOptions[Int](commonOptions) { _ =>
handleCommandRun(remaining)
pc.withOptions[Int](commonOptions) { _ =>
handleCommandRun(remaining)
}
case None =>
// arguments are bad, error message will have been displayed
pc.log.info("Option parsing failed, terminating.")
1
end match

catch
case NonFatal(exception) =>
pc.log.severe("Exception Thrown:", exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.utils.{CommonOptions, PlatformContext, StringHelpers}

import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.io.File
import java.nio.file.Path
import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}

/** Unit Tests For FromCommand */
object FromCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ package com.ossuminc.riddl.commands
import com.ossuminc.riddl.command.{Command, CommandOptions, CommonOptionsHelper}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.utils.{CommonOptions, PlatformContext, Logger}
import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import com.ossuminc.riddl.utils.{CommonOptions, Logger, PlatformContext}
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser
import scopt.RenderingMode.OneColumn

import java.nio.file.Path
import com.ossuminc.riddl.command.{Command, CommandOptions}

/** Unit Tests For FromCommand */
object HelpCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.language.Messages
import com.ossuminc.riddl.command.CommandOptions.optional
import com.ossuminc.riddl.command.{CommandOptions, PassCommand}
import com.ossuminc.riddl.hugo.HugoPass
import com.ossuminc.riddl.hugo.themes.{DotdockWriter, GeekDocWriter}
import com.ossuminc.riddl.command.CommandOptions
import com.ossuminc.riddl.command.CommandOptions.optional
import com.ossuminc.riddl.command.PassCommand
import com.ossuminc.riddl.language.Messages
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassCreators
import com.ossuminc.riddl.utils.PlatformContext
import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.net.URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.command.{Command, CommandOptions}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.command.{Command, CommandOptions}
import com.ossuminc.riddl.utils.{PlatformContext, RiddlBuildInfo}

import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,20 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.language.Messages.errors
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.command.CommandOptions
import com.ossuminc.riddl.command.{Command, CommandOptions}
import com.ossuminc.riddl.command.CommandOptions.optional
import com.ossuminc.riddl.command.Command
import com.ossuminc.riddl.language.Messages.{Messages, errors}
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.utils.PlatformContext

import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import pureconfig.{ConfigCursor, ConfigReader}
import pureconfig.error.CannotParse
import scopt.OParser

import java.io.File
import java.nio.file.Path
import pureconfig.error.CannotParse

import java.nio.file.{Files, Path}
import java.nio.file.attribute.FileTime
import java.nio.file.Files
import java.time.Instant
import scala.concurrent.duration.Duration
import scala.concurrent.duration.DurationInt
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.duration.{Duration, DurationInt, FiniteDuration}

object OnChangeCommand {
final val cmdName: String = "onchange"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
package com.ossuminc.riddl.commands

import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.language.parsing.TopLevelParser
import com.ossuminc.riddl.language.parsing.RiddlParserInput
import com.ossuminc.riddl.language.parsing.{RiddlParserInput, TopLevelParser}
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.utils.{Await, PlatformContext}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.command.CommandOptions.optional
import com.ossuminc.riddl.command.{CommandOptions, PassCommandOptions, TranslationCommand}
import com.ossuminc.riddl.language.{At, Messages}
import com.ossuminc.riddl.passes.Pass.standardPasses
import com.ossuminc.riddl.passes.{PassCreators, PassInput, PassOptions, PassesOutput, PassesResult}
import com.ossuminc.riddl.utils.{ExceptionUtils, PlatformContext}
import com.ossuminc.riddl.command.{CommandOptions, PassCommandOptions, TranslationCommand}
import com.ossuminc.riddl.command.CommandOptions.optional
import com.ossuminc.riddl.passes.prettify.{PrettifyOutput, PrettifyPass, RiddlFileEmitter}

import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import com.ossuminc.riddl.passes.*
import com.ossuminc.riddl.utils.{ExceptionUtils, PlatformContext}
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.nio.charset.Charset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.command.{Command, CommandOptions}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.PassesResult
import com.ossuminc.riddl.command.{Command, CommandOptions}
import com.ossuminc.riddl.utils.{PlatformContext, Interrupt}

import pureconfig.ConfigCursor
import pureconfig.ConfigReader
import com.ossuminc.riddl.utils.{Interrupt, PlatformContext}
import pureconfig.{ConfigCursor, ConfigReader}
import pureconfig.ConfigReader.Result
import pureconfig.error.CannotParse
import scopt.OParser

import java.io.File
import java.nio.file.Path
import scala.concurrent.duration.Duration
import scala.concurrent.duration.DurationInt
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.duration.{Duration, DurationInt, FiniteDuration}
import scala.util.Success

object RepeatCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.command.{PassCommand, PassCommandOptions}
import com.ossuminc.riddl.language.Messages
import com.ossuminc.riddl.passes.Pass.standardPasses
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.passes.*
import com.ossuminc.riddl.passes.Pass.standardPasses
import com.ossuminc.riddl.passes.stats.{KindStats, StatsOutput, StatsPass}
import com.ossuminc.riddl.utils.PlatformContext
import scopt.OParser
import pureconfig.{ConfigCursor, ConfigReader}
import scopt.OParser

import java.io.File
import java.nio.file.Path
import com.ossuminc.riddl.command.{PassCommand, PassCommandOptions}
import com.ossuminc.riddl.passes.stats.{KindStats, StatsOutput, StatsPass}

object StatsCommand {
val cmdName: String = "stats"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

package com.ossuminc.riddl.commands

import com.ossuminc.riddl.utils.{Await, PlatformContext}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.language.parsing.RiddlParserInput
import com.ossuminc.riddl.passes.{PassesResult, Riddl}
import com.ossuminc.riddl.utils.{Await, PlatformContext}

import java.nio.file.Path
import scala.concurrent.ExecutionContext
Expand All @@ -24,7 +24,7 @@ class ValidateCommand(using pc: PlatformContext) extends InputFileCommand("valid
outputDirOverride: Option[Path]
): Either[Messages, PassesResult] = {
options.withInputFile { (inputFile: Path) =>
implicit val ec: ExecutionContext = pc.ec
implicit val ec: ExecutionContext = pc.ec
val future = RiddlParserInput.fromPath(inputFile.toString).map { rpi =>
Riddl.parseAndValidate(rpi)
}
Expand Down
Loading

0 comments on commit 2bf4ce4

Please sign in to comment.