Correct server type check
Checking the serverType/subcommand from string input. Before the check was done after parsing string input, when an unknown server type was entered a "Too many arguments!" error was issued due to the parser falsely interpreting the input.
This commit is contained in:
parent
81350db43d
commit
949fe0c1af
1 changed files with 7 additions and 1 deletions
|
@ -19,9 +19,15 @@ fun main(args: Array<String>) {
|
||||||
|
|
||||||
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
||||||
|
|
||||||
|
// validate subcommand
|
||||||
|
if (!ServerType.values().any {it.name.lowercase() == args[0]}) {
|
||||||
|
println("Unknown serverType. Currently only k3s is accepted.")
|
||||||
|
exitProcess(1)
|
||||||
|
}
|
||||||
|
|
||||||
val cmd = CliArgumentsParser("provs-server.jar subcommand target").parseCommand(checkedArgs)
|
val cmd = CliArgumentsParser("provs-server.jar subcommand target").parseCommand(checkedArgs)
|
||||||
|
|
||||||
// input validation
|
// validate parsed arguments
|
||||||
if (!cmd.isValidTarget()) {
|
if (!cmd.isValidTarget()) {
|
||||||
println("Remote or localhost not valid, please try -h for help.")
|
println("Remote or localhost not valid, please try -h for help.")
|
||||||
exitProcess(1)
|
exitProcess(1)
|
||||||
|
|
Loading…
Reference in a new issue