Skip to content

Commit

Permalink
fix(deps): update dependency com.github.ajalt.clikt:clikt to v5 (#2798)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency com.github.ajalt.clikt:clikt to v5

* Upgrade com.github.ajalt.clikt:clikt to v5

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Paul Dingemans <paul-dingemans@users.noreply.github.com>
  • Loading branch information
renovate[bot] and paul-dingemans committed Sep 24, 2024
1 parent 1c2ec01 commit 65978a1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlinx-binary-compatibiltiy-validator = "org.jetbrains.kotlinx.binary-compatibi
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-plugin-dev = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinDev" }
clikt = "com.github.ajalt.clikt:clikt:4.4.0"
clikt = "com.github.ajalt.clikt:clikt:5.0.0"
dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.9.20"
ec4j = "org.ec4j.core:ec4j-core:0.3.0"
logging = "io.github.oshai:kotlin-logging-jvm:7.0.0"
Expand Down
1 change: 1 addition & 0 deletions ktlint-cli/src/main/kotlin/com/pinterest/ktlint/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.pinterest.ktlint

import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.subcommands
import com.pinterest.ktlint.cli.internal.GenerateEditorConfigSubCommand
import com.pinterest.ktlint.cli.internal.GitPreCommitHookSubCommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pinterest.ktlint.cli.internal

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.enum
Expand All @@ -14,11 +15,10 @@ import java.nio.file.Paths

private val LOGGER = KotlinLogging.logger {}.initKtLintKLogger()

internal class GenerateEditorConfigSubCommand :
CliktCommand(
name = "generateEditorConfig",
help = "Generate kotlin style section for '.editorconfig' file. Output should be copied manually to the '.editorconfig' file.",
) {
internal class GenerateEditorConfigSubCommand : CliktCommand(name = "generateEditorConfig") {
override fun help(context: Context) =
"Generate kotlin style section for '.editorconfig' file. Output should be copied manually to the '.editorconfig' file."

// No default value is set as users should explicitly choose one of the code styles. In this way, it is more clear that the generated
// content is determined by the chosen value. If a default (ktlint_official) is set, and the user has not specified the code style, the
// user might not be aware that the value of the other properties are dependent on the code style.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pinterest.ktlint.cli.internal

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import java.io.File
import java.io.IOException
import java.math.BigInteger
Expand All @@ -11,8 +12,10 @@ private const val DEFAULT_GIT_HOOKS_DIR = "hooks"

internal abstract class GitHookCliktCommand(
name: String,
help: String,
) : CliktCommand(name = name, help = help) {
val helpText: String,
) : CliktCommand(name = name) {
override fun help(context: Context) = helpText

fun installGitHook(
gitHookName: String,
hookContentProvider: () -> ByteArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.pinterest.ktlint.cli.internal
internal class GitPreCommitHookSubCommand :
GitHookCliktCommand(
name = "installGitPreCommitHook",
help = "Install git hook to automatically check files for style violations on commit",
helpText = "Install git hook to automatically check files for style violations on commit",
) {
override fun run() {
installGitHook(gitHookName = "pre-commit") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.pinterest.ktlint.cli.internal
internal class GitPrePushHookSubCommand :
GitHookCliktCommand(
name = "installGitPrePushHook",
help = "Install git hook to automatically check files for style violations before push",
helpText = "Install git hook to automatically check files for style violations before push",
) {
override fun run() {
installGitHook(gitHookName = "pre-push") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.pinterest.ktlint.cli.internal
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.MutuallyExclusiveGroupException
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.multiple
Expand Down Expand Up @@ -67,51 +68,50 @@ import kotlin.system.exitProcess

private lateinit var logger: KLogger

internal class KtlintCommandLine :
CliktCommand(
name = "ktlint",
invokeWithoutSubcommand = true,
help =
"""
An anti-bikeshedding Kotlin linter with built-in formatter.
(https://pinterest.github.io/ktlint/latest/).
internal class KtlintCommandLine : CliktCommand(name = "ktlint") {
override fun help(context: Context) =
"""
An anti-bikeshedding Kotlin linter with built-in formatter.
(https://pinterest.github.io/ktlint/latest/).
Usage on Windows:
java -jar ktlint.jar [<options>] [<arguments>]... <command> [<args>]...
Usage on Windows:
java -jar ktlint.jar [<options>] [<arguments>]... <command> [<args>]...
# EXAMPLES
# EXAMPLES
## Use default patterns
## Use default patterns
Check the style of all Kotlin files (ending with '.kt' or '.kts') inside the current dir (recursively). Hidden folders will be skipped.
Check the style of all Kotlin files (ending with '.kt' or '.kts') inside the current dir (recursively). Hidden folders will be skipped.
`ktlint`
`ktlint`
## Specify patterns
## Specify patterns
Check only certain locations starting from the current directory. Prepend ! to negate the pattern, KtLint uses .gitignore pattern style syntax. Globs are applied starting from the last one.
Check only certain locations starting from the current directory. Prepend ! to negate the pattern, KtLint uses .gitignore pattern style syntax. Globs are applied starting from the last one.
Check all '.kt' files in 'src/' directory, but ignore files ending with 'Test.kt':
Check all '.kt' files in 'src/' directory, but ignore files ending with 'Test.kt':
`ktlint "src/**/*.kt" "!src/**/*Test.kt"`
`ktlint "src/**/*.kt" "!src/**/*Test.kt"`
Check all '.kt' files in 'src/' directory, but ignore 'generated' directory and its subdirectories:
Check all '.kt' files in 'src/' directory, but ignore 'generated' directory and its subdirectories:
`ktlint "src/**/*.kt" "!src/**/generated/**"`
`ktlint "src/**/*.kt" "!src/**/generated/**"`
## Auto-correct style violations
## Auto-correct style violations
Check all '.kt' files in 'src/' directory, and when possible automatically correct the lint violations:
Check all '.kt' files in 'src/' directory, and when possible automatically correct the lint violations:
`ktlint -F "src/**/*.kt"`
`ktlint -F "src/**/*.kt"`
## Using custom reporter jar and overriding report location
## Using custom reporter jar and overriding report location
`ktlint --reporter=csv,artifact=/path/to/reporter/csv.jar,output=my-custom-report.csv`
`ktlint --reporter=csv,artifact=/path/to/reporter/csv.jar,output=my-custom-report.csv`
# Options and commands
""".trimIndent()

override val invokeWithoutSubcommand = true

# Options and commands
""".trimIndent(),
) {
init {
versionOption(KtlintVersionProvider().version, names = setOf("-v", "--version"))
}
Expand Down

0 comments on commit 65978a1

Please sign in to comment.