11package io.github.legion2.open_cue_cli
22
3+ import com.github.ajalt.clikt.completion.CompletionCandidates
34import com.github.ajalt.clikt.core.CliktCommand
45import com.github.ajalt.clikt.parameters.arguments.argument
56import com.github.ajalt.clikt.parameters.options.default
@@ -9,7 +10,7 @@ import com.github.ajalt.clikt.parameters.types.int
910import com.github.ajalt.clikt.parameters.types.restrictTo
1011import io.github.legion2.open_cue_cli.CliContext.Companion.createCliContext
1112
12- class OpenCueCli : CliktCommand (name = " open-cue-cli" ) {
13+ class OpenCueCli : CliktCommand (name = " open-cue-cli" , autoCompleteEnvvar = " OPEN_CUE_CLI_COMPLETE " ) {
1314 private val port: Int by option(" -p" , " --port" , help = " Port of the Open CUE Service" , metavar = " <port>" )
1415 .int().restrictTo(min = 0 ).default(25555 )
1516 private val host: String by option(" -H" , " --host" , help = " Hostname or ip address of the Open CUE Service" ,
@@ -28,4 +29,5 @@ val <T> Iterable<T>.echoString: String get() = joinToString("\n")
2829
2930fun <T > Iterable<T>.echoString (transform : (T ) -> CharSequence ): String = joinToString(" \n " , transform = transform)
3031
31- fun CliktCommand.profileArgument (help : String? = null) = argument(" profile" , help = help ? : " The name of the profile" )
32+ fun CliktCommand.profileArgument (help : String? = null) = argument(" profile" , help = help ? : " The name of the profile" ,
33+ completionCandidates = CompletionCandidates .Custom .fromStdout(" (test -x ./open-cue-cli && ./open-cue-cli profile list) || (hash open-cue-cli 2>/dev/null && open-cue-cli profile list)" ))
0 commit comments