-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
77 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
41 changes: 0 additions & 41 deletions
41
vgo-cli/src/main/kotlin/com/jzbrooks/vgo/cli/Application.kt
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
vgo-cli/src/main/kotlin/com/jzbrooks/vgo/cli/CommandLineInterface.kt
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,65 @@ | ||
package com.jzbrooks.vgo.cli | ||
|
||
import com.jzbrooks.vgo.Vgo | ||
import kotlin.system.exitProcess | ||
|
||
class CommandLineInterface { | ||
fun run(args: Array<String>): Int { | ||
val argReader = ArgReader(args.toMutableList()) | ||
|
||
val printHelp = argReader.readFlag("help|h") | ||
if (printHelp) { | ||
println(HELP_MESSAGE) | ||
return 0 | ||
} | ||
|
||
val printVersion = argReader.readFlag("version|v") | ||
val printStats = argReader.readFlag("stats|s") | ||
val indent = argReader.readOption("indent")?.toIntOrNull() | ||
|
||
val outputs = | ||
run { | ||
val outputPaths = mutableListOf<String>() | ||
var output = argReader.readOption("output|o") | ||
while (output != null) { | ||
outputPaths.add(output) | ||
output = argReader.readOption("output|o") | ||
} | ||
outputPaths.toList() | ||
} | ||
|
||
var format = argReader.readOption("format") | ||
|
||
var inputs = argReader.readArguments() | ||
|
||
val options = | ||
Vgo.Options( | ||
printVersion = printVersion, | ||
printStats = printStats, | ||
indent = indent, | ||
output = outputs, | ||
format = format, | ||
input = inputs, | ||
) | ||
|
||
return Vgo(options).run() | ||
} | ||
|
||
companion object { | ||
private val HELP_MESSAGE = | ||
""" | ||
> vgo [options] [file/directory] | ||
Options: | ||
-h --help print this message | ||
-o --output file or directory, if not provided the input will be overwritten | ||
-s --stats print statistics on processed files to standard out | ||
-v --version print the version number | ||
--indent value write files with value columns of indentation | ||
--format value output format (svg, vd, etc) | ||
""".trimIndent() | ||
|
||
@JvmStatic | ||
fun main(args: Array<String>): Unit = exitProcess(CommandLineInterface().run(args)) | ||
} | ||
} |
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