From faa72740f8d475ea88ec05c5bdcbabec61393f82 Mon Sep 17 00:00:00 2001 From: OSS-Bot <93565511+slack-oss-bot@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:40:34 -0700 Subject: [PATCH] Update dependency com.github.ajalt.clikt:clikt to v5 (#968) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [com.github.ajalt.clikt:clikt](https://redirect.github.com/ajalt/clikt) | dependencies | major | `4.4.0` -> `5.0.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes
ajalt/clikt (com.github.ajalt.clikt:clikt) ### [`v5.0.0`](https://redirect.github.com/ajalt/clikt/blob/HEAD/CHANGELOG.md#500) [Compare Source](https://redirect.github.com/ajalt/clikt/compare/4.4.0...5.0.0) ##### Added - Publish `iosArm64` and `iosX64` targets. - Added `NoSuchArgument` exception that is thrown when too many arguments were given on the command line. Previously, a less specific `UsageError` was thrown instead. - Added `CommandLineParser.tokenize` that splits a string into argv tokens. - Added `CommandLineParser` that provides functions for parsing and finalizing commands manually for more control. - Added `Context.invokedSubcommands` that contains all subcommands of the current command that are going to be invoked when `allowMultipleSubcommands` is `true`. - Added `SuspendingCliktCommand` that has a `suspend fun run` method, allowing you to use coroutines in your commands. - Added `ChainedCliktCommand` that allows you to return a value from your `run` method and pass it to the next command in the chain. - Added `Context.data` as an alternative to `obj` that allows you to store more than one object in the context. - Added `Context.echoer` to customize how `echo` messages are printed. - Added `CompletionGenerator` to manually generate completions for a command. - Added `Context.exitProcess` which you can use to prevent the process from exiting during tests. - Added core module that supports watchOS, tvOS, and wasmWasi targets and has no dependencies. - Added more options to `CliktCommand.test` to control the terminal interactivity. ([#​517](https://redirect.github.com/ajalt/clikt/pull/517)) - Added `associate{}`, `associateBy{}`, and `associateWith{}` transforms for options that allow you to convert the keys and values of the map. ([#​529](https://redirect.github.com/ajalt/clikt/pull/529)) - Added support for aliasing options to other options. ([#​535](https://redirect.github.com/ajalt/clikt/pull/535)) - Added `limit` and `ignoreCase` parameters to `option().split()`. ([#​541](https://redirect.github.com/ajalt/clikt/pull/541)) - Support calling `--help` on subcommands when parents have required parameters. ##### Changed - In a subcommand with and an `argument()` with `multiple()` or `optional()`, the behavior is now the same regardless of the value of `allowMultipleSubcommands`: if a token matches a subcommand name, it's now treated as a subcommand rather than a positional argument. - Due to changes to the internal parsing algorithm, the exact details of error messages when multiple usage errors occur have changed in some cases. - **Breaking Change:** Moved the following parameters from `CliktCommand`'s constructor; override the corresponding properties instead: | removed parameter | replacement property | |-----------------------------|---------------------------------| | `help` | `fun help` | | `epilog` | `fun helpEpilog` | | `invokeWithoutSubcommand` | `val invokeWithoutSubcommand` | | `printHelpOnEmptyArgs` | `val printHelpOnEmptyArgs` | | `helpTags` | `val helpTags` | | `autoCompleteEnvvar` | `val autoCompleteEnvvar` | | `allowMultipleSubcommands` | `val allowMultipleSubcommands` | | `treatUnknownOptionsAsArgs` | `val treatUnknownOptionsAsArgs` | | `hidden` | `val hiddenFromHelp` | - The following methods on `CliktCommand` have been renamed: `commandHelp` -> `help`, `commandHelpEpilog` -> `epilog`. The old names are deprecated. - **Breaking Change:** `CliktCommand.main` and `CliktCommand.parse` are now extension functions rather than methods. - **Breaking Change:** `Context.obj` and `Context.terminal`, and `OptionTransformContext.terminal` are now extension functions rather than properties. - **Breaking Change:** The `RenderedSection` and `DefinitionRow` classes have moved to `AbstractHelpFormatter`. - Markdown support in the help formatter is no longer included by default. To enable it, include the `:clikt-markdown` dependency and call `yourCommand.installMordantMarkdown()` before parsing. - Updated Kotlin to 2.0.0 ##### Fixed - Fixed excess arguments not being reported when `allowMultipleSubcommands=true` and a subcommand has excess arguments followed by another subcommand. - Commands with `printHelpOnEmptyArgs=true` will no longer print help if an option has a value from an environment variable or value source. ([#​382](https://redirect.github.com/ajalt/clikt/pull/382)) ##### Deprecated - Deprecated `Context.originalArgv`. It will now always return an empty list. If your commands need an argv, you can pass it to them before you run them, or set in on the new `Context.data` map. - Deprecated `Context.expandArgumentFiles`. Use `Context.argumentFileReader` instead. - Renamed the following `Context` fields to be more consistent. The old names are deprecated. | old name | new name | |-------------------------------|---------------------------------| | `Context.envvarReader` | `Context.readEnvvar` | | `Context.correctionSuggestor` | `Context.suggestTypoCorrection` | | `Context.argumentFileReader` | `Context.readArgumentFile` | | `Context.tokenTransformer` | `Context.transformToken` | ##### Removed - Removed previously deprecated experimental annotations. - Removed `MordantHelpFormatter.graphemeLength` - Removed `TermUi`
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://redirect.github.com/renovatebot/renovate). --------- Co-authored-by: Zac Sweers --- gradle/libs.versions.toml | 2 +- .../kotlin/com/slack/skippy/CliktSgpLogger.kt | 7 +++-- .../skippy/ComputeAffectedProjectsCli.kt | 28 ++++++++----------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 51c5652a0..c592dde55 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,7 +64,7 @@ agpAlpha = { module = "com.android.tools.build:gradle", version.ref = "agpAlpha" autoService-annotations = "com.google.auto.service:auto-service-annotations:1.1.1" autoService-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.2.0" bugsnag = "com.bugsnag:bugsnag:3.7.2" -clikt = "com.github.ajalt.clikt:clikt:4.4.0" +clikt = "com.github.ajalt.clikt:clikt:5.0.0" circuit-foundation = { module = "com.slack.circuit:circuit-foundation", version.ref = "circuit" } commonsText = "org.apache.commons:commons-text:1.12.0" composeLints = "com.slack.lint.compose:compose-lint-checks:1.3.1" diff --git a/skippy/src/main/kotlin/com/slack/skippy/CliktSgpLogger.kt b/skippy/src/main/kotlin/com/slack/skippy/CliktSgpLogger.kt index 7ccd1bfe7..5b0e73d81 100644 --- a/skippy/src/main/kotlin/com/slack/skippy/CliktSgpLogger.kt +++ b/skippy/src/main/kotlin/com/slack/skippy/CliktSgpLogger.kt @@ -15,12 +15,13 @@ */ package com.slack.skippy -import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.BaseCliktCommand import com.slack.sgp.common.SgpLogger -internal fun SgpLogger.Companion.clikt(command: CliktCommand): SgpLogger = CliktSgpLogger(command) +internal fun SgpLogger.Companion.clikt(command: BaseCliktCommand<*>): SgpLogger = + CliktSgpLogger(command) -private class CliktSgpLogger(private val command: CliktCommand) : SgpLogger { +private class CliktSgpLogger(private val command: BaseCliktCommand<*>) : SgpLogger { override fun debug(message: String) { command.echo(message) } diff --git a/skippy/src/main/kotlin/com/slack/skippy/ComputeAffectedProjectsCli.kt b/skippy/src/main/kotlin/com/slack/skippy/ComputeAffectedProjectsCli.kt index c4f2aa220..614056c89 100644 --- a/skippy/src/main/kotlin/com/slack/skippy/ComputeAffectedProjectsCli.kt +++ b/skippy/src/main/kotlin/com/slack/skippy/ComputeAffectedProjectsCli.kt @@ -15,7 +15,8 @@ */ package com.slack.skippy -import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.command.SuspendingCliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required @@ -33,7 +34,6 @@ import kotlin.io.path.readText import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.newFixedThreadPoolContext -import kotlinx.coroutines.runBlocking import okio.FileSystem import okio.Path.Companion.toOkioPath @@ -41,10 +41,10 @@ import okio.Path.Companion.toOkioPath * @see AffectedProjectsComputer for most of the salient docs! The inputs in this CLI more or less * match 1:1 to the properties of that class. */ -public class ComputeAffectedProjectsCli : - CliktCommand( - help = "Computes affected projects and writes output files to an output directory." - ) { +public class ComputeAffectedProjectsCli : SuspendingCliktCommand() { + + override fun help(context: Context): String = + "Computes affected projects and writes output files to an output directory." private val debug: Boolean by option("--debug", help = "Enable debug logging.").flag(default = false) @@ -102,7 +102,7 @@ public class ComputeAffectedProjectsCli : private val logger = SgpLogger.clikt(this) @OptIn(DelicateCoroutinesApi::class) - override fun run() { + override suspend fun run() { val moshi = Moshi.Builder().build() val dependencyGraph = ObjectInputStream(serializedDependencyGraph.inputStream()).use { @@ -136,15 +136,11 @@ public class ComputeAffectedProjectsCli : .run(context) } - runBlocking { - if (parallelism == 1) { - body(Dispatchers.Unconfined) - } else { - logger.lifecycle("Running $parallelism configs in parallel") - newFixedThreadPoolContext(3, "computeAffectedProjects").use { dispatcher -> - body(dispatcher) - } - } + if (parallelism == 1) { + body(Dispatchers.Unconfined) + } else { + logger.lifecycle("Running $parallelism configs in parallel") + newFixedThreadPoolContext(3, "computeAffectedProjects").use { dispatcher -> body(dispatcher) } } } }