Skip to content

Commit ebf52ae

Browse files
committed
added bash completion feature
1 parent a23dbc2 commit ebf52ae

6 files changed

Lines changed: 36 additions & 19 deletions

File tree

.github/workflows/build.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
name: Build
22

3-
on: [ push, pull_request ]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- name: Setup Java JDK 8
11-
uses: actions/setup-java@v1.3.0
12-
with:
13-
java-version: 8
14-
- name: Gradle Build
15-
run: gradle build
16-
- name: Upload distribution archive
17-
uses: actions/upload-artifact@v2-preview
18-
with:
19-
name: open-cue-cli.zip
20-
path: build/distributions/open-cue-cli.zip
9+
- uses: actions/checkout@v2
10+
- name: Setup Java JDK 8
11+
uses: actions/setup-java@v1.3.0
12+
with:
13+
java-version: 8
14+
- name: Gradle Build
15+
run: gradle build
16+
- name: Generate Bash Completion
17+
env:
18+
OPEN_CUE_CLI_COMPLETE: bash
19+
run: |
20+
unzip build/distributions/open-cue-cli.zip
21+
./open-cue-cli/open-cue-cli > open-cue-cli/bash-complete-open-cue-cli.sh
22+
chmod +x open-cue-cli/bash-complete-open-cue-cli.sh
23+
- name: Upload distribution archive
24+
uses: actions/upload-artifact@v2-preview
25+
with:
26+
name: open-cue-cli
27+
path: open-cue-cli/

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
java-version: 8
1616
- name: Gradle Build
1717
run: gradle build
18+
- name: Generate Bash Completion
19+
env:
20+
OPEN_CUE_CLI_COMPLETE: bash
21+
run: |
22+
unzip build/distributions/open-cue-cli.zip
23+
./open-cue-cli/open-cue-cli > open-cue-cli/bash-complete-open-cue-cli.sh
24+
chmod +x open-cue-cli/bash-complete-open-cue-cli.sh
25+
zip open-cue-cli.zip open-cue-cli
1826
- name: Get upload url
1927
id: release-id
2028
run: |
@@ -27,6 +35,6 @@ jobs:
2735
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2836
with:
2937
upload_url: ${{ steps.release-id.outputs.upload_url }}
30-
asset_path: build/distributions/open-cue-cli.zip
38+
asset_path: open-cue-cli.zip
3139
asset_name: open-cue-cli.zip
3240
asset_content_type: application/zip

Readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ Test=245
6464
```
6565
Profile names **MUST** only contain normal characters "a-z", "A-Z" and "_".
6666
Also don't use language specific characters like ä and é.
67+
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.
6768
The priorities comes into play when you activate two profiles, then the profile with the higher priority is shown on top of the other.
6869

69-
> `default` is not allowed as profile name.
70-
7170
## Packaging of this application
7271
This package is provide as zip containing executables and dependencies as jars.
7372
A Java Runtime Environment (JRE) must be installed to run the application.

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
3030
jvmTarget = "1.8"
3131
languageVersion = "1.3"
3232
apiVersion = "1.3"
33+
freeCompilerArgs += "-Xopt-in=com.github.ajalt.clikt.completion.ExperimentalCompletionCandidates"
3334
}
3435
}
3536

src/main/kotlin/io/github/legion2/open_cue_cli/OpenCueCli.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.legion2.open_cue_cli
22

3+
import com.github.ajalt.clikt.completion.CompletionCandidates
34
import com.github.ajalt.clikt.core.CliktCommand
45
import com.github.ajalt.clikt.parameters.arguments.argument
56
import com.github.ajalt.clikt.parameters.options.default
@@ -9,7 +10,7 @@ import com.github.ajalt.clikt.parameters.types.int
910
import com.github.ajalt.clikt.parameters.types.restrictTo
1011
import 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

2930
fun <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)"))

src/main/kotlin/io/github/legion2/open_cue_cli/profile/ListProfiles.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class ListProfiles : CliktCommand("List all available profiles for the current g
1414
private val cliContext by requireObject<CliContext>()
1515
override fun run() = runBlocking {
1616
val profiles = cliContext.sdkClient.listProfiles()
17-
echo(profiles.sortedBy { it.priority }.echoString { profile -> if (details) profile.echoString else profile.name })
17+
echo(profiles.sortedBy { it.priority }.echoString { profile -> if (details) profile.echoString else profile.name }, lineSeparator = "\n")
1818
}
1919
}

0 commit comments

Comments
 (0)