make target mandatory (either local or remote)
This commit is contained in:
parent
cae96ca42f
commit
c2e2c12e76
1 changed files with 8 additions and 3 deletions
|
@ -7,6 +7,7 @@ import kotlinx.cli.optional
|
||||||
|
|
||||||
class CliCommand(
|
class CliCommand(
|
||||||
val remoteHost: String?,
|
val remoteHost: String?,
|
||||||
|
val localHost: Boolean?,
|
||||||
val userName: String?,
|
val userName: String?,
|
||||||
val sshWithGopassPath: String?,
|
val sshWithGopassPath: String?,
|
||||||
val sshWithPasswordPrompt: Boolean,
|
val sshWithPasswordPrompt: Boolean,
|
||||||
|
@ -20,7 +21,7 @@ class CliCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isValidLocalhost(): Boolean {
|
fun isValidLocalhost(): Boolean {
|
||||||
return remoteHost == null && userName == null && sshWithGopassPath == null &&
|
return (localHost ?: false) && remoteHost == null && userName == null && sshWithGopassPath == null &&
|
||||||
!sshWithPasswordPrompt && !sshWithKey
|
!sshWithPasswordPrompt && !sshWithKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +45,11 @@ fun parseCli(args: Array<String>): CliCommand {
|
||||||
|
|
||||||
val remoteHost by parser.option(
|
val remoteHost by parser.option(
|
||||||
ArgType.String, shortName =
|
ArgType.String, shortName =
|
||||||
"r", description = "provision remote host"
|
"r", description = "provision to remote host - either localHost or remoteHost must be specified"
|
||||||
|
)
|
||||||
|
val localHost by parser.option(
|
||||||
|
ArgType.Boolean, shortName =
|
||||||
|
"l", description = "provision to local machine - either localHost or remoteHost must be specified"
|
||||||
)
|
)
|
||||||
val userName by parser.option(
|
val userName by parser.option(
|
||||||
ArgType.String,
|
ArgType.String,
|
||||||
|
@ -69,7 +74,7 @@ fun parseCli(args: Array<String>): CliCommand {
|
||||||
parser.parse(args)
|
parser.parse(args)
|
||||||
val cliCommand =
|
val cliCommand =
|
||||||
CliCommand(
|
CliCommand(
|
||||||
remoteHost, userName, sshWithGopassPath, sshWithPasswordPrompt, sshWithKey, configFileName
|
remoteHost, localHost, userName, sshWithGopassPath, sshWithPasswordPrompt, sshWithKey, configFileName
|
||||||
)
|
)
|
||||||
return cliCommand
|
return cliCommand
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue