-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from akilegaspi/master
Improving CLI tooltip and usage
- Loading branch information
Showing
13 changed files
with
117 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ target/ | |
*/target | ||
**/target | ||
.bsp/* | ||
.bst/**/* | ||
.bsp/**/* |
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,11 +1,15 @@ | ||
ThisBuild / version := "0.1.0-SNAPSHOT" | ||
|
||
ThisBuild / scalaVersion := "2.13.11" | ||
ThisBuild / scalaVersion := "2.13.13" | ||
|
||
ThisBuild / organization := "com.skyline.warlangmod" | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
name := "WarThunder Language Updater", | ||
assembly / mainClass := Some("com.skyline.warlangmod.Main"), | ||
libraryDependencies ++= Seq( | ||
"com.monovore" %% "decline" % "2.4.1", | ||
"org.scalameta" %% "munit" % "0.7.29" % Test, | ||
), | ||
) |
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,15 @@ | ||
package com.skyline.warlangmod | ||
|
||
import java.io.FileWriter | ||
|
||
object App { | ||
def run(inputFileName: String, originalFile: String, outputFileName: String): Unit = { | ||
val parsingService = ParsingService.instance | ||
val translationOverwrite = TranslationOverwriteService.instance | ||
val outputService = Output.instance | ||
val moddedTranslations = parsingService.translations(inputFileName) | ||
val originalUpdatedTranslations = parsingService.translations(originalFile) | ||
val updatedModdedFile = translationOverwrite.overwrite(originalUpdatedTranslations, moddedTranslations) | ||
outputService.write(updatedModdedFile, outputFileName) | ||
} | ||
} |
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,22 +1,31 @@ | ||
package com.skyline.warlangmod | ||
|
||
import java.io.FileWriter | ||
import com.monovore.decline._ | ||
|
||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
import cats.implicits._ | ||
|
||
if(args.length < 2) | ||
System.exit(1) // No input file | ||
object Main extends CommandApp( | ||
name = "WarThunder Translation Updater", | ||
header = "A tool to update the translation files for WarThunder ", | ||
main = { | ||
val defaultInFile = "units.csv" | ||
val defaultOriginalFile = "unitsN.csv" | ||
val defaultOutFile = "unitsMod.csv" | ||
val originalFile = Opts.option[String]( | ||
long = "original", | ||
short = "r", | ||
help = s"The original file to be updated, defaults to $defaultOriginalFile when not provided").withDefault(defaultOriginalFile) | ||
val inFile = Opts.option[String]( | ||
long = "input", | ||
short = "i", | ||
help = s"The input file to be updated, defaults to $defaultInFile when not provided").withDefault(defaultInFile) | ||
val outFile = Opts.option[String]( | ||
long = "output", | ||
short = "o", | ||
help = s"The output file to be written to, defaults $defaultOutFile when not provided").withDefault(defaultOutFile) | ||
|
||
val parsingService = ParsingService() | ||
val translationOverwriter = TranslationOverwriteService() | ||
val outputService = Output() | ||
|
||
val moddedTranslations = parsingService.translations(args(0)) | ||
val originalUpdatedTranslations = parsingService.translations(args(1)) | ||
|
||
val uptodateModdedTranslationFile = translationOverwriter.overwrite(originalUpdatedTranslations, moddedTranslations) | ||
|
||
outputService.write(uptodateModdedTranslationFile) | ||
(inFile, originalFile, outFile).mapN { | ||
(inputFileName, originalFileName, outputFileName) => App.run(inputFileName, originalFileName, outputFileName) | ||
} | ||
} | ||
} | ||
) |
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
20 changes: 11 additions & 9 deletions
20
src/main/scala/com/skyline/warlangmod/ParsingService.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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package com.skyline.warlangmod | ||
|
||
import scala.io.Source | ||
|
||
/** | ||
* For parsing language/translation files of WarThunder | ||
*/ | ||
|
||
trait ParsingService { | ||
def translations(filename: String): Translations | ||
} | ||
|
||
object ParsingService { | ||
|
||
def apply(): ParsingService = new ParsingService { | ||
import scala.io.Source | ||
override def translations(filename: String): Translations = { | ||
val langFile = Source.fromFile(filename) | ||
val translations = Language.parse(langFile) | ||
langFile.close() | ||
translations | ||
} | ||
|
||
lazy val instance: ParsingService = (filename: String) => { | ||
val langFile = Source.fromFile(filename) | ||
val translations = Language.parse(langFile) | ||
langFile.close() | ||
translations | ||
} | ||
|
||
} |
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,5 +1,8 @@ | ||
package com.skyline.warlangmod | ||
|
||
/** | ||
* A trait for objects that can be rendered as a string. | ||
*/ | ||
trait Renderable { | ||
def render(): String | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/test/scala/com/skyline/warlangmod/ParsingServiceInstanceSpec.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 com.skyline.warlangmod | ||
|
||
import java.io.FileWriter | ||
import java.nio.file.Files | ||
|
||
class ParsingServiceInstanceSpec extends munit.FunSuite { | ||
test("ParsingServiceInstance should parse a WarThunder Translation file format") { | ||
val translations = Translations( | ||
languages = Vector( | ||
Language("something", "good") | ||
) | ||
) | ||
val tmpFile = Files.createTempFile("ParsingServiceInstanceTestFile", null) | ||
val writer = new FileWriter(tmpFile.toFile) | ||
writer.write(translations.render()) | ||
writer.close() | ||
val parsedTranslation = ParsingService.instance.translations(tmpFile.toAbsolutePath.toString) | ||
assertEquals(parsedTranslation, translations) | ||
} | ||
} |