Skip to content

Commit 7c87796

Browse files
authored
Mark CompletionCandidates.Custom as experimental (#120)
1 parent c3bbf9d commit 7c87796

File tree

7 files changed

+25
-3
lines changed

7 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
## [Unreleased]
44
### Added
55
- `CompletionCandidates.Fixed` now has a secondary convenience constructor that take a `vararg` of `String`s
6-
- `CompletionCadidates.Custom`, which allows you to call other binaries or write a script to generate completions.
6+
- `CompletionCadidates.Custom`, which allows you to call other binaries or write a script to generate completions. This class is currently experimental. ([#79](https://github.com/ajalt/clikt/issues/79))
77
- `Option.wrapValue` and `Argument.wrapValue` to make it easier to reuse existing conversion functions.
88
- `ignoreCase` parameter to `choice()` and `enum()` conversion functions.
99

1010
### Changed
1111
- `option()` and `argument()` now take optional `completionCandidates` parameters to override how completion is generated. The constructor and `copy` functions of `OptionsWithValues` and `ProcessedArgument` have changed to support default values.
12-
- The overloads of `findObject` ([1](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.core/-context/find-object/) [2](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.core/find-object/)) that take a default value have been renamed `findOrSetObject`. The existing names are marked with `@Deprecated`, and IntelliJ can convert your callsites automatically.
13-
- `enum()` parameters now accept case-insensitive values by default. You change this behavior by passing `ignoreCase = false` to `enum()`
12+
- The overloads of `findObject` ([1](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.core/-context/find-object/) [2](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.core/find-object/)) that take a default value have been renamed `findOrSetObject`. The existing names are marked with `@Deprecated`, and IntelliJ can convert your callsites automatically. ([#110](https://github.com/ajalt/clikt/issues/110))
13+
- `enum()` parameters now accept case-insensitive values by default. You change this behavior by passing `ignoreCase = false` to `enum()` ([#115](https://github.com/ajalt/clikt/issues/115))
1414

1515
### Fixed
1616
- `groupChoice` help output now includes the choices in the help output metavar

clikt/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ buildscript {
1515
}
1616
}
1717

18+
compileKotlin {
19+
kotlinOptions {
20+
freeCompilerArgs += "-Xuse-experimental=kotlin.Experimental"
21+
}
22+
}
23+
24+
compileTestKotlin {
25+
kotlinOptions {
26+
freeCompilerArgs += "-Xuse-experimental=kotlin.Experimental"
27+
}
28+
}
29+
1830
task sourcesJar(type: Jar, dependsOn: classes) {
1931
classifier = 'sources'
2032
from sourceSets.main.allSource

clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionCandidates.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.github.ajalt.clikt.completion
22

3+
@Experimental
4+
@Retention(AnnotationRetention.BINARY)
5+
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
6+
annotation class ExperimentalCompletionCandidates
7+
38
/**
49
* Configurations for generating shell autocomplete suggestions
510
*/
@@ -38,6 +43,7 @@ sealed class CompletionCandidates {
3843
* word being typed. The word being typed can be retrieved from the `COMP_WORDS` array at index
3944
* `COMP_CWORD`.
4045
*/
46+
@ExperimentalCompletionCandidates
4147
data class Custom(val generator: (ShellType) -> String?) : CompletionCandidates() {
4248
enum class ShellType { BASH }
4349
companion object {

clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionGenerator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.github.ajalt.clikt.completion.CompletionCandidates.Custom.ShellType
44
import com.github.ajalt.clikt.core.CliktCommand
55

66
internal object CompletionGenerator {
7+
@UseExperimental(ExperimentalCompletionCandidates::class)
78
fun generateCompletion(command: CliktCommand, zsh: Boolean = true): String {
89
val commandName = command.commandName
910
val (isTopLevel, funcName) = commandCompletionFuncName(command)

clikt/src/main/kotlin/com/github/ajalt/clikt/parameters/arguments/Argument.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ inline fun <T : Any> RawArgument.convert(
375375
level = DeprecationLevel.ERROR
376376
)
377377
@JvmName("rawWrapValue")
378+
@Suppress("UNUSED_PARAMETER")
378379
fun RawArgument.wrapValue(wrapper: (String) -> Any): RawArgument = this
379380

380381
/**

clikt/src/main/kotlin/com/github/ajalt/clikt/parameters/options/OptionWithValues.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ inline fun <T : Any> RawOption.convert(
595595
level = DeprecationLevel.ERROR
596596
)
597597
@JvmName("rawWrapValue")
598+
@Suppress("UNUSED_PARAMETER")
598599
fun RawOption.wrapValue(wrapper: (String) -> Any): RawOption = this
599600

600601
/**

clikt/src/test/kotlin/com/github/ajalt/clikt/completion/CompletionTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.junit.Rule
1212
import org.junit.Test
1313
import org.junit.contrib.java.lang.system.EnvironmentVariables
1414

15+
@UseExperimental(ExperimentalCompletionCandidates::class)
1516
@Suppress("unused")
1617
class CompletionTest {
1718
@Rule

0 commit comments

Comments
 (0)