-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advance parsing of ElmProject (#296)
* Introduce about command * MorphirConfig * Upgrade to 0.12.0 * Add some custom types around the hosting package * Add the EnvironmentNameSpec * Clean up Hosting types a bit * Cleanup the CLI a bit * Tidying up CLI related items * Adding additional subcommands for morphir-elm * Adding ElmCaching related items * Experiment with jsoniter-scala * Have an example of using neotype with jsoniter-scala * Added version number parsing and Conf codec * Ensure ElmVersion JSON serialization/deserialization works * Ensure JsonCodec and JsonKeyCodec for ElmDependencyMap works * Cleanup the ElmModuleName and ElmPackageVersion a bit * Setting up testing for ElmDependencyMap * Including validation of ElmDependencyMap * Did some basic work on ElmApplication
- Loading branch information
1 parent
3b51b5d
commit 2753034
Showing
60 changed files
with
1,358 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
package org.finos.morphir.cli | ||
import org.finos.morphir.cli.command.* | ||
import caseapp.* | ||
import caseapp.core.help.* | ||
object Main extends CommandsEntryPoint: | ||
|
||
override def commands: Seq[Command[?]] = Seq( | ||
Make, | ||
Develop, | ||
Setup, | ||
Config | ||
) | ||
|
||
override def helpFormat: HelpFormat = | ||
super.helpFormat.copy(sortedCommandGroups = Some(Seq("Main", "Setup & Configuration"))) | ||
|
||
// TODO: Use the BuildInfo plugin to get the progName | ||
override def progName: String = "morphir" | ||
import commands.{About, Config, Develop, Make, Setup} | ||
object Main: | ||
def main(args: Array[String]): Unit = | ||
val commands = new MorphirCliCommands("morphir-cli", "morphir-cli", "Morphir CLI") | ||
commands.main(args) |
20 changes: 20 additions & 0 deletions
20
morphir/cli/src/org/finos/morphir/cli/MorphirCliCommand.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.finos.morphir.cli | ||
import caseapp.* | ||
import kyo.* | ||
import org.finos.morphir.config.* | ||
import org.finos.morphir.cli.options.OptionGroup | ||
import caseapp.core.help.HelpFormat | ||
|
||
abstract class MorphirCliCommand[T](using parser: Parser[T], help: Help[T]) extends Command[T]()(parser, help): | ||
|
||
def run(options: T, remainingArgs: RemainingArgs): Unit = | ||
KyoApp.run(runEffect(options, remainingArgs)) | ||
|
||
def runEffect(options: T, remainingArgs: RemainingArgs): Unit < (Async & Resource & Abort[Throwable]) | ||
|
||
override def helpFormat: HelpFormat = super.helpFormat.copy( | ||
sortedGroups = Some(OptionGroup.order) | ||
) | ||
|
||
object MorphirCliCommand: | ||
type Effects = KyoApp.Effects & Env[MorphirConfig] |
35 changes: 35 additions & 0 deletions
35
morphir/cli/src/org/finos/morphir/cli/MorphirCliCommands.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.finos.morphir.cli | ||
import caseapp.CommandsEntryPoint | ||
import caseapp.core.app.Command | ||
import caseapp.core.help.* | ||
import commands.{About, Config, Develop, Make, Setup} | ||
import org.finos.morphir.cli.options.* | ||
import org.finos.morphir.cli.commands.ConfigSet | ||
import org.finos.morphir.cli.commands.ConfigSet.ConfigGet | ||
import org.finos.morphir.cli.MorphirCliCommand | ||
|
||
class MorphirCliCommands( | ||
val progName: String, | ||
val baseRunnerName: String, | ||
val fullRunnerName: String | ||
) extends CommandsEntryPoint { | ||
|
||
private def allCommands: Seq[MorphirCliCommand[?]] = Seq( | ||
About, | ||
Make, | ||
Develop, | ||
Setup, | ||
ConfigGet, | ||
Config, | ||
ConfigSet | ||
) | ||
|
||
def commands: Seq[Command[?]] = allCommands | ||
|
||
override def helpFormat: HelpFormat = | ||
super.helpFormat.copy( | ||
sortedGroups = Some(OptionGroup.order), | ||
sortedCommandGroups = Some(Seq("Main", "Setup & Configuration")) | ||
) | ||
|
||
} |
13 changes: 0 additions & 13 deletions
13
morphir/cli/src/org/finos/morphir/cli/command/config.scala
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
morphir/cli/src/org/finos/morphir/cli/commands/about.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.finos.morphir.cli.commands | ||
|
||
import caseapp.* | ||
import kyo.* | ||
import org.finos.morphir.build.BuildInfo | ||
import org.finos.morphir.cli.{given, *} | ||
|
||
@HelpMessage("Display information about the Morphir CLI") | ||
final case class AboutOptions() | ||
|
||
object About extends MorphirCliCommand[AboutOptions]: | ||
override def group = "Information" | ||
def runEffect(options: AboutOptions, remainingArgs: RemainingArgs) = | ||
defer { | ||
println("_____________________________________________________________") | ||
println("Morphir CLI - A command line interface for Morphir.") | ||
println("_____________________________________________________________") | ||
|
||
val table = t2.TableBuilder() | ||
.add("#", "Property", "Value") | ||
.add("1", "Version", BuildInfo.version) | ||
.add("2", "Scala Version", BuildInfo.scalaVersion) | ||
.add("3", "Build Time", BuildInfo.buildTime) | ||
.add("4", "Java Version", await(System.property[String]("java.version", "N/A"))) | ||
.add("5", "Java Home", await(System.property[String]("java.home", "N/A"))) | ||
.add("6", "OS", s"${await(System.property[String]("os.name"))} ${await(System.property[String]("os.version"))}") | ||
.add("7", "User", await(System.property[String]("user.name", "N/A"))) | ||
// TODO: Add info about Morphir Home and Setup state | ||
.build() | ||
|
||
// Create table writer with supplied configuration | ||
val writer = t2.TableWriter( | ||
"ansiColorEnabled" -> "true", | ||
"tableBorderColor" -> "cyan", | ||
"tableHeaderColor" -> "black,yellowBackground", | ||
"bodyRuleColor" -> "yellow", | ||
"rowHeaderEnabled" -> "true", | ||
"rowHeaderColor" -> "bold,cyan", | ||
"maxValueSize" -> "60", | ||
"truncateEnabled" -> "false" | ||
) | ||
|
||
writer.write(java.lang.System.out, table) | ||
} |
46 changes: 46 additions & 0 deletions
46
morphir/cli/src/org/finos/morphir/cli/commands/config.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.finos.morphir.cli.commands | ||
|
||
import caseapp.* | ||
import kyo.* | ||
import org.finos.morphir.cli.{given, *} | ||
import caseapp.core.Arg | ||
|
||
@HelpMessage("Work with Morphir related configuration") | ||
final case class ConfigOptions() | ||
|
||
object Config extends MorphirCliCommand[ConfigOptions]: | ||
override def group = "Setup & Configuration" | ||
def runEffect(options: ConfigOptions, remainingArgs: RemainingArgs) = | ||
defer { | ||
pprint.log("ConfigOptions:") | ||
pprint.log(options) | ||
pprint.log("Remaining Args:") | ||
pprint.log(remainingArgs) | ||
} | ||
|
||
@HelpMessage("Set configuration options") | ||
final case class ConfigSetOptions(key: String) | ||
object ConfigSet extends MorphirCliCommand[ConfigSetOptions]: | ||
override def names: List[List[String]] = List(List("config", "set")) | ||
override def group = "Setup & Configuration" | ||
def runEffect(options: ConfigSetOptions, remainingArgs: RemainingArgs) = | ||
defer { | ||
pprint.log("ConfigSetOptions:") | ||
pprint.log(options) | ||
pprint.log("Remaining Args:") | ||
pprint.log(remainingArgs) | ||
} | ||
|
||
@HelpMessage("Get configuration options") | ||
@ArgsName("key") | ||
final case class ConfigGetOptions() | ||
object ConfigGet extends MorphirCliCommand[ConfigGetOptions]: | ||
override def names: List[List[String]] = List(List("config", "get")) | ||
override def group = "Setup & Configuration" | ||
def runEffect(options: ConfigGetOptions, remainingArgs: RemainingArgs) = | ||
defer { | ||
pprint.log("ConfigGetOptions:") | ||
pprint.log(options) | ||
pprint.log("Remaining Args:") | ||
pprint.log(remainingArgs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.