Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Add Gradle test fixtures migrator CLI #181

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/kotlin-cli-util.api
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public final class slack/cli/CliUtilKt {
public static synthetic fun filterByName$default (Lkotlin/sequences/Sequence;Ljava/lang/String;ZILjava/lang/Object;)Lkotlin/sequences/Sequence;
public static final fun filterByNamePath (Lkotlin/sequences/Sequence;Ljava/lang/String;Z)Lkotlin/sequences/Sequence;
public static synthetic fun filterByNamePath$default (Lkotlin/sequences/Sequence;Ljava/lang/String;ZILjava/lang/Object;)Lkotlin/sequences/Sequence;
public static final fun multipleSet (Lcom/github/ajalt/clikt/parameters/options/OptionWithValues;Ljava/util/Set;Z)Lcom/github/ajalt/clikt/parameters/options/OptionWithValues;
public static synthetic fun multipleSet$default (Lcom/github/ajalt/clikt/parameters/options/OptionWithValues;Ljava/util/Set;ZILjava/lang/Object;)Lcom/github/ajalt/clikt/parameters/options/OptionWithValues;
public static final fun skipBuildAndCacheDirs (Lkotlin/io/FileTreeWalk;)Lkotlin/io/FileTreeWalk;
public static final fun skipBuildAndCacheDirs (Lkotlin/io/path/FileVisitorBuilder;)V
public static final fun walkEachFile (Ljava/nio/file/Path;IZLkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
Expand All @@ -49,6 +51,11 @@ public final class slack/cli/CommandFactoryKt {
public static synthetic fun runCommand$default ([Ljava/lang/String;ZILjava/lang/Object;)V
}

public final class slack/cli/Playground {
public static final fun main ()V
public static synthetic fun main ([Ljava/lang/String;)V
}

public final class slack/cli/Toml {
public static final field INSTANCE Lslack/cli/Toml;
public final fun parseVersion (Ljava/io/File;)Ljava/util/Map;
Expand Down Expand Up @@ -3463,6 +3470,21 @@ public final class slack/cli/gradle/GradleSettingsVerifierCli$Factory : slack/cl
public fun getKey ()Ljava/lang/String;
}

public final class slack/cli/gradle/GradleTestFixturesMigratorCli : com/github/ajalt/clikt/core/CliktCommand {
public static final field ANDROID_TEST_FIXTURES_BLOCK Ljava/lang/String;
public static final field DESCRIPTION Ljava/lang/String;
public static final field JAVA_FIXTURES_BLOCK Ljava/lang/String;
public fun <init> ()V
public fun run ()V
}

public final class slack/cli/gradle/GradleTestFixturesMigratorCli$Factory : slack/cli/CommandFactory {
public fun <init> ()V
public fun create ()Lcom/github/ajalt/clikt/core/CliktCommand;
public fun getDescription ()Ljava/lang/String;
public fun getKey ()Ljava/lang/String;
}

public final class slack/cli/lint/LintBaselineMergerCli : com/github/ajalt/clikt/core/CliktCommand {
public static final field DESCRIPTION Ljava/lang/String;
public fun <init> ()V
Expand Down
32 changes: 32 additions & 0 deletions src/main/kotlin/slack/cli/CliUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package slack.cli

import com.github.ajalt.clikt.core.MissingOption
import com.github.ajalt.clikt.parameters.options.NullableOption
import com.github.ajalt.clikt.parameters.options.OptionWithValues
import com.github.ajalt.clikt.parameters.options.transformAll
import java.io.File
import java.nio.file.FileVisitResult
import java.nio.file.Path
Expand Down Expand Up @@ -127,3 +131,31 @@ private fun List<String>.padNewline(): List<String> {
val noEmpties = dropLastWhile { it.isBlank() }
return noEmpties + ""
}

/**
* Make the option return a set of calls; each item in the set is the value of one call.
*
* If the option is never called, the set will be empty. This must be applied after all other
* transforms.
*
* ### Example:
* ```
* val opt: Set<Pair<Int, Int>> by option().int().pair().multipleSet()
* ```
*
* @param default The value to use if the option is not supplied. Defaults to an empty set.
* @param required If true, [default] is ignored and [MissingOption] will be thrown if no instances
* of the option are present on the command line.
*/
public fun <EachT, ValueT> NullableOption<EachT, ValueT>.multipleSet(
default: Set<EachT> = emptySet(),
required: Boolean = false,
): OptionWithValues<Set<EachT>, EachT, ValueT> {
return transformAll(showAsRequired = required) {
when {
it.isEmpty() && required -> throw MissingOption(option)
it.isEmpty() && !required -> default
else -> it
}.toSet()
}
}
Loading