Skip to content

Commit

Permalink
Bump clikt 4.4.0 -> 5.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wmontwe committed Dec 4, 2024
1 parent 4a30419 commit bb523a5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import app.k9mail.autodiscovery.autoconfig.createMxLookupAutoconfigDiscovery
import app.k9mail.autodiscovery.autoconfig.createProviderAutoconfigDiscovery
import app.k9mail.core.common.mail.toUserEmailAddress
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
Expand All @@ -17,14 +18,15 @@ import kotlinx.coroutines.runBlocking
import okhttp3.OkHttpClient.Builder
import org.koin.core.time.measureDurationForResult

class AutoDiscoveryCli : CliktCommand(
help = "Performs the auto-discovery steps used by Thunderbird for Android to find mail server settings",
) {
class AutoDiscoveryCli : CliktCommand() {
private val httpsOnly by option(help = "Only perform Autoconfig lookups using HTTPS").flag()
private val includeEmailAddress by option(help = "Include email address in Autoconfig lookups").flag()

private val emailAddress by argument(name = "email", help = "Email address")

override fun help(context: Context) =
"Performs the auto-discovery steps used by Thunderbird for Android to find mail server settings"

override fun run() {
echo("Attempting to find mail server settings for <$emailAddress>…")
echo()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package app.k9mail.cli.autodiscovery

import com.github.ajalt.clikt.core.main

fun main(args: Array<String>) = AutoDiscoveryCli().main(args)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app.k9mail.cli.html.cleaner
import app.k9mail.html.cleaner.HtmlHeadProvider
import app.k9mail.html.cleaner.HtmlProcessor
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.optional
import com.github.ajalt.clikt.parameters.types.file
Expand All @@ -13,16 +15,17 @@ import okio.sink
import okio.source

@Suppress("MemberVisibilityCanBePrivate")
class HtmlCleaner : CliktCommand(
help = "A tool that modifies HTML to only keep allowed elements and attributes the same way that K-9 Mail does.",
) {
class HtmlCleaner : CliktCommand() {
val input by argument(help = "HTML input file (needs to be UTF-8 encoded)")
.inputStream()

val output by argument(help = "Output file")
.file(mustExist = false, canBeDir = false)
.optional()

override fun help(context: Context) =
"A tool that modifies HTML to only keep allowed elements and attributes the same way that K-9 Mail does."

override fun run() {
val html = readInput()
val processedHtml = cleanHtml(html)
Expand All @@ -34,9 +37,11 @@ class HtmlCleaner : CliktCommand(
}

private fun cleanHtml(html: String): String {
val htmlProcessor = HtmlProcessor(object : HtmlHeadProvider {
override val headHtml = """<meta name="viewport" content="width=device-width"/>"""
})
val htmlProcessor = HtmlProcessor(
object : HtmlHeadProvider {
override val headHtml = """<meta name="viewport" content="width=device-width"/>"""
},
)

return htmlProcessor.processForDisplay(html)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package net.thunderbird.cli.resource.mover

import com.github.ajalt.clikt.core.main

fun main(args: Array<String>) = ResourceMoverCli().main(args)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.thunderbird.cli.resource.mover

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.options.split
Expand All @@ -9,7 +10,6 @@ class ResourceMoverCli(
private val stringResourceMover: StringResourceMover = StringResourceMover(),
) : CliktCommand(
name = "resource-mover",
help = "Move string resources from one file to another",
) {
private val from: String by option(
help = "Source module path",
Expand All @@ -23,6 +23,8 @@ class ResourceMoverCli(
help = "Keys to move",
).split(",").required()

override fun help(context: Context): String = "Move string resources from one file to another"

override fun run() {
stringResourceMover.moveKeys(from, to, keys)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package net.thunderbird.cli.translation

import com.github.ajalt.clikt.core.main

fun main(args: Array<String>) = TranslationCli().main(args)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.thunderbird.cli.translation

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
Expand All @@ -15,7 +16,6 @@ class TranslationCli(
private val supportedLanguagesFormatter: SupportedLanguagesFormatter = SupportedLanguagesFormatter(),
) : CliktCommand(
name = "translation",
help = "Translation CLI",
) {
private val token: String by option(
help = "Weblate API token",
Expand All @@ -29,6 +29,8 @@ class TranslationCli(
help = "Print code example",
).flag()

override fun help(context: Context): String = "Translation CLI"

override fun run() {
val languageCodes = languageCodeLoader.loadCurrentAndroidLanguageCodes(token, threshold)
val size = languageCodes.size
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ appAuth = "0.11.1"
assertk = "0.28.1"
circleImageView = "3.1.0"
ckchangelog = "2.0.0-beta02"
clikt = "4.4.0"
clikt = "5.0.2"
commonsIo = "2.16.1"
dependencyCheckPlugin = "0.51.0"
dependencyGuardPlugin = "0.5.0"
Expand Down

0 comments on commit bb523a5

Please sign in to comment.