diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fccc3fa..99a0747 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,27 @@ name: Build -on: [ push, pull_request ] +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Java JDK 8 - uses: actions/setup-java@v1.3.0 - with: - java-version: 8 - - name: Gradle Build - run: gradle build - - name: Upload distribution archive - uses: actions/upload-artifact@v2-preview - with: - name: open-cue-cli.zip - path: build/distributions/open-cue-cli.zip + - uses: actions/checkout@v2 + - name: Setup Java JDK 8 + uses: actions/setup-java@v1.3.0 + with: + java-version: 8 + - name: Gradle Build + run: gradle build + - name: Generate Bash Completion + env: + OPEN_CUE_CLI_COMPLETE: bash + run: | + unzip build/distributions/open-cue-cli.zip + ./open-cue-cli/open-cue-cli > open-cue-cli/bash-complete-open-cue-cli.sh + chmod +x open-cue-cli/bash-complete-open-cue-cli.sh + - name: Upload distribution archive + uses: actions/upload-artifact@v2-preview + with: + name: open-cue-cli + path: open-cue-cli/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da96c16..30929ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,14 @@ jobs: java-version: 8 - name: Gradle Build run: gradle build + - name: Generate Bash Completion + env: + OPEN_CUE_CLI_COMPLETE: bash + run: | + unzip build/distributions/open-cue-cli.zip + ./open-cue-cli/open-cue-cli > open-cue-cli/bash-complete-open-cue-cli.sh + chmod +x open-cue-cli/bash-complete-open-cue-cli.sh + zip open-cue-cli.zip open-cue-cli - name: Get upload url id: release-id run: | @@ -27,6 +35,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.release-id.outputs.upload_url }} - asset_path: build/distributions/open-cue-cli.zip + asset_path: open-cue-cli.zip asset_name: open-cue-cli.zip asset_content_type: application/zip diff --git a/Readme.md b/Readme.md index ec27d44..d8c9c44 100644 --- a/Readme.md +++ b/Readme.md @@ -64,10 +64,9 @@ Test=245 ``` Profile names **MUST** only contain normal characters "a-z", "A-Z" and "_". Also don't use language specific characters like ä and é. +You must set the name of the profile, when you export it from iCUE, you can't change it later, because it's stored inside the profile file. The priorities comes into play when you activate two profiles, then the profile with the higher priority is shown on top of the other. -> `default` is not allowed as profile name. - ## Packaging of this application This package is provide as zip containing executables and dependencies as jars. A Java Runtime Environment (JRE) must be installed to run the application. diff --git a/build.gradle.kts b/build.gradle.kts index e68d95a..0093763 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ tasks.withType { jvmTarget = "1.8" languageVersion = "1.3" apiVersion = "1.3" + freeCompilerArgs += "-Xopt-in=com.github.ajalt.clikt.completion.ExperimentalCompletionCandidates" } } diff --git a/src/main/kotlin/io/github/legion2/open_cue_cli/OpenCueCli.kt b/src/main/kotlin/io/github/legion2/open_cue_cli/OpenCueCli.kt index ca76f81..a8e50a3 100644 --- a/src/main/kotlin/io/github/legion2/open_cue_cli/OpenCueCli.kt +++ b/src/main/kotlin/io/github/legion2/open_cue_cli/OpenCueCli.kt @@ -1,5 +1,6 @@ package io.github.legion2.open_cue_cli +import com.github.ajalt.clikt.completion.CompletionCandidates import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.options.default @@ -9,7 +10,7 @@ import com.github.ajalt.clikt.parameters.types.int import com.github.ajalt.clikt.parameters.types.restrictTo import io.github.legion2.open_cue_cli.CliContext.Companion.createCliContext -class OpenCueCli : CliktCommand(name = "open-cue-cli") { +class OpenCueCli : CliktCommand(name = "open-cue-cli", autoCompleteEnvvar = "OPEN_CUE_CLI_COMPLETE") { private val port: Int by option("-p", "--port", help = "Port of the Open CUE Service", metavar = "") .int().restrictTo(min = 0).default(25555) private val host: String by option("-H", "--host", help = "Hostname or ip address of the Open CUE Service", @@ -28,4 +29,5 @@ val Iterable.echoString: String get() = joinToString("\n") fun Iterable.echoString(transform: (T) -> CharSequence): String = joinToString("\n", transform = transform) -fun CliktCommand.profileArgument(help: String? = null) = argument("profile", help = help ?: "The name of the profile") +fun CliktCommand.profileArgument(help: String? = null) = argument("profile", help = help ?: "The name of the profile", + 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)")) diff --git a/src/main/kotlin/io/github/legion2/open_cue_cli/profile/ListProfiles.kt b/src/main/kotlin/io/github/legion2/open_cue_cli/profile/ListProfiles.kt index d0673ca..34c5ec8 100644 --- a/src/main/kotlin/io/github/legion2/open_cue_cli/profile/ListProfiles.kt +++ b/src/main/kotlin/io/github/legion2/open_cue_cli/profile/ListProfiles.kt @@ -14,6 +14,6 @@ class ListProfiles : CliktCommand("List all available profiles for the current g private val cliContext by requireObject() override fun run() = runBlocking { val profiles = cliContext.sdkClient.listProfiles() - echo(profiles.sortedBy { it.priority }.echoString { profile -> if (details) profile.echoString else profile.name }) + echo(profiles.sortedBy { it.priority }.echoString { profile -> if (details) profile.echoString else profile.name }, lineSeparator = "\n") } }