Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency com.github.ajalt.clikt:clikt to v5 #968

Merged
merged 2 commits into from
Sep 18, 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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions skippy/src/main/kotlin/com/slack/skippy/CliktSgpLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,18 +34,17 @@ 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

/**
* @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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) }
}
}
}