Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 1f3a3d0a authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #8647 from wmontwe/update-clikt

Update clikt
parents e4ea53f9 eaf7b12a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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
@@ -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()
+2 −0
Original line number Diff line number Diff line
package app.k9mail.cli.autodiscovery

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

fun main(args: Array<String>) = AutoDiscoveryCli().main(args)
+11 −6
Original line number Diff line number Diff line
@@ -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
@@ -13,9 +15,7 @@ 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()

@@ -23,6 +23,9 @@ class HtmlCleaner : CliktCommand(
        .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)
@@ -34,9 +37,11 @@ class HtmlCleaner : CliktCommand(
    }

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

        return htmlProcessor.processForDisplay(html)
    }
+2 −0
Original line number Diff line number Diff line
package net.thunderbird.cli.resource.mover

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

fun main(args: Array<String>) = ResourceMoverCli().main(args)
+3 −1
Original line number Diff line number Diff line
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
@@ -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",
@@ -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)
    }
Loading