diff --git a/actions/src/Actions.kt b/actions/src/Actions.kt index bd0fd81..e9a9626 100644 --- a/actions/src/Actions.kt +++ b/actions/src/Actions.kt @@ -35,7 +35,7 @@ internal val ACTION_MODULE by DI.Module { bind { singleton { - instance().takeIf { it.info.outputInteractive } + instance().takeIf { it.terminalInfo.outputInteractive } ?.let { TerminalNotificationService(it) } ?: SystemNotificationService() } @@ -111,8 +111,8 @@ private fun getFormattedHelp(error: CliktError, rootCommand: CliktCommand, symli .joinToString(" ") return ctx.helpFormatter(ctx).formatHelp( error as? UsageError, - command.commandHelp(ctx), - command.commandHelpEpilog(ctx), + command.help(ctx), + command.helpEpilog(ctx), command.allHelpParams(), programName, ) diff --git a/actions/src/commands/AttachCommand.kt b/actions/src/commands/AttachCommand.kt index 260979c..66572e8 100644 --- a/actions/src/commands/AttachCommand.kt +++ b/actions/src/commands/AttachCommand.kt @@ -3,6 +3,7 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.Abort import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.core.Context import com.github.hubvd.odootools.actions.utils.Odooctl import com.github.hubvd.odootools.actions.utils.selectInstance import org.http4k.core.HttpHandler @@ -12,9 +13,9 @@ import org.http4k.core.Request class AttachCommand( private val odooctl: Odooctl, private val httpHandler: HttpHandler, -) : CliktCommand( - help = "Attach the selected odoo instances to a remote debugger", -) { +) : CliktCommand() { + override fun help(context: Context) = "Attach the selected odoo instances to a remote debugger" + override fun run() { val instances = odooctl.instances() if (instances.isEmpty()) throw CliktError("No instances running") diff --git a/actions/src/commands/BisectCommand.kt b/actions/src/commands/BisectCommand.kt index 4fdec87..9210719 100644 --- a/actions/src/commands/BisectCommand.kt +++ b/actions/src/commands/BisectCommand.kt @@ -2,6 +2,7 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.Abort import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option @@ -91,9 +92,8 @@ class BisectCommand( private val runbot: Runbot, private val workspaces: Workspaces, private val git: Git, -) : CliktCommand( - help = "Bisect odoo across multiple repositories", -) { +) : CliktCommand() { + override fun help(context: Context) = "Bisect odoo across multiple repositories" private lateinit var odooLegacyRepository: LegacyRepository private lateinit var enterpriseLegacyRepository: LegacyRepository diff --git a/actions/src/commands/CheckoutCommand.kt b/actions/src/commands/CheckoutCommand.kt index d056834..cbd2b41 100644 --- a/actions/src/commands/CheckoutCommand.kt +++ b/actions/src/commands/CheckoutCommand.kt @@ -2,30 +2,36 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.defaultLazy -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.actions.kitty.Kitty -import com.github.hubvd.odootools.actions.utils.* +import com.github.hubvd.odootools.actions.utils.BranchLookup +import com.github.hubvd.odootools.actions.utils.BranchRef +import com.github.hubvd.odootools.actions.utils.Clipboard +import com.github.hubvd.odootools.actions.utils.NotificationService import com.github.hubvd.odootools.workspace.Workspaces import com.github.pgreze.process.Redirect.CAPTURE import com.github.pgreze.process.Redirect.SILENT import com.github.pgreze.process.process -import kotlinx.coroutines.* +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.runBlocking import java.io.File class CheckoutCommand( private val workspaces: Workspaces, - private val terminal: Terminal, private val notificationService: NotificationService, private val branchLookup: BranchLookup, private val kitty: Kitty, -) : CliktCommand( - help = "Checkout a pull request from a github url or a commit ref (remote:branch)", -) { +) : CliktCommand() { + override fun help(context: Context) = "Checkout a pull request from a github url or a commit ref (remote:branch)" + private val branch by argument().defaultLazy { Clipboard.read() } override fun run() { + val terminal = currentContext.terminal val ref = branchLookup(branch) ?: throw CliktError("Couldn't extract base branch") @@ -47,7 +53,7 @@ class CheckoutCommand( async { fetchAndCheckout(ref, workspace.path.resolve("odoo").toFile()) }, async { fetchAndCheckout(ref, workspace.path.resolve("enterprise").toFile()) }, ) - if (!terminal.info.outputInteractive) { + if (!terminal.terminalInfo.outputInteractive) { kitty.openGit(workspace, odoo, enterprise) } } diff --git a/actions/src/commands/KillCommand.kt b/actions/src/commands/KillCommand.kt index aceede8..65942fa 100644 --- a/actions/src/commands/KillCommand.kt +++ b/actions/src/commands/KillCommand.kt @@ -5,11 +5,10 @@ import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.optional import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.actions.utils.Odooctl import com.github.hubvd.odootools.actions.utils.selectInstance -class KillCommand(private val odooctl: Odooctl, private val terminal: Terminal) : CliktCommand() { +class KillCommand(private val odooctl: Odooctl) : CliktCommand() { private val all by option("-a", "--all").flag() private val database by argument().optional() diff --git a/actions/src/commands/NewCommand.kt b/actions/src/commands/NewCommand.kt index c1d9c84..45a77df 100644 --- a/actions/src/commands/NewCommand.kt +++ b/actions/src/commands/NewCommand.kt @@ -2,6 +2,7 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.Abort 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.arguments.defaultLazy import com.github.ajalt.clikt.parameters.arguments.optional @@ -18,9 +19,9 @@ class NewCommand( private val workspaces: Workspaces, private val notificationService: NotificationService, private val config: ActionsConfig, -) : CliktCommand( - help = "Create or switch to a branch with the selected id", -) { +) : CliktCommand() { + override fun help(context: Context) = "Create or switch to a branch with the selected id" + private val isSentry by option("-s", "--sentry").flag() private val id by argument().int().defaultLazy { Clipboard.read().toInt() } private val description by argument().optional() diff --git a/actions/src/commands/OdooctlCommand.kt b/actions/src/commands/OdooctlCommand.kt index d5ce6e3..a3f343f 100644 --- a/actions/src/commands/OdooctlCommand.kt +++ b/actions/src/commands/OdooctlCommand.kt @@ -1,16 +1,17 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.mordant.rendering.TextColors import com.github.ajalt.mordant.table.Borders import com.github.ajalt.mordant.table.table -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.actions.utils.Odooctl -class OdooctlCommand(private val odooctl: Odooctl, private val terminal: Terminal) : CliktCommand( - help = "List information about running odoo instances", - invokeWithoutSubcommand = true, -) { +class OdooctlCommand(private val odooctl: Odooctl) : CliktCommand() { + override fun help(context: Context) = "List information about running odoo instances" + override val invokeWithoutSubcommand = true + override fun run() { if (currentContext.invokedSubcommand != null) return diff --git a/actions/src/commands/OpenCommand.kt b/actions/src/commands/OpenCommand.kt index 07e8839..d135fc2 100644 --- a/actions/src/commands/OpenCommand.kt +++ b/actions/src/commands/OpenCommand.kt @@ -1,6 +1,7 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.parameters.groups.mutuallyExclusiveOptions import com.github.ajalt.clikt.parameters.groups.single import com.github.ajalt.clikt.parameters.options.convert @@ -10,9 +11,9 @@ import com.github.hubvd.odootools.actions.utils.BrowserService import com.github.hubvd.odootools.actions.utils.Odooctl import com.github.hubvd.odootools.actions.utils.selectInstance -class OpenCommand(private val odooctl: Odooctl, private val browserService: BrowserService) : CliktCommand( - help = "Open the selected odoo instance in a web browser", -) { +class OpenCommand(private val odooctl: Odooctl, private val browserService: BrowserService) : CliktCommand() { + override fun help(context: Context) = "Open the selected odoo instance in a web browser" + private val type by mutuallyExclusiveOptions( option("-q", "--qunit").flag().convert { Type.QUnit }, option("-h", "--hoot", "-u", "--unit").flag().convert { Type.Hoot }, diff --git a/actions/src/commands/OpenerCommand.kt b/actions/src/commands/OpenerCommand.kt index c4f3d28..d3886dc 100644 --- a/actions/src/commands/OpenerCommand.kt +++ b/actions/src/commands/OpenerCommand.kt @@ -2,6 +2,7 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.Abort 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.arguments.defaultLazy import com.github.ajalt.clikt.parameters.groups.mutuallyExclusiveOptions @@ -12,7 +13,9 @@ import com.github.ajalt.clikt.parameters.options.option import com.github.hubvd.odootools.actions.utils.BrowserService import com.github.hubvd.odootools.actions.utils.Clipboard -class OpenerCommand(private val browserService: BrowserService) : CliktCommand(help = "Opens a PR/Task") { +class OpenerCommand(private val browserService: BrowserService) : CliktCommand() { + override fun help(context: Context) = "Opens a PR/Task" + private val input by argument().defaultLazy { Clipboard.read(selection = true) } private val type by mutuallyExclusiveOptions( diff --git a/actions/src/commands/PycharmCommand.kt b/actions/src/commands/PycharmCommand.kt index a8e5cfe..2dd5f24 100644 --- a/actions/src/commands/PycharmCommand.kt +++ b/actions/src/commands/PycharmCommand.kt @@ -2,15 +2,16 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.Abort 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.arguments.multiple import com.github.hubvd.odootools.actions.utils.Pycharm import com.github.hubvd.odootools.actions.utils.menu import com.github.hubvd.odootools.workspace.Workspaces -class PycharmCommand(private val workspaces: Workspaces) : CliktCommand( - help = "Open selected files in Pycharm", -) { +class PycharmCommand(private val workspaces: Workspaces) : CliktCommand() { + override fun help(context: Context) = "Open selected files in Pycharm" + private val paths by argument().multiple() private val pathRe = "^(?.*?)(?:#(?\\d+)(?::(?\\d+))?)?\$".toRegex() diff --git a/actions/src/commands/QrCommand.kt b/actions/src/commands/QrCommand.kt index b6c1acc..2bc0bfa 100644 --- a/actions/src/commands/QrCommand.kt +++ b/actions/src/commands/QrCommand.kt @@ -1,6 +1,8 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.mordant.rendering.* import com.github.ajalt.mordant.table.grid import com.github.ajalt.mordant.terminal.Terminal @@ -15,12 +17,11 @@ import kotlin.streams.asSequence private data class Interface(val name: String, val address: Inet4Address) class QrCommand( - private val terminal: Terminal, private val odooctl: Odooctl, private val workspaces: Workspaces, -) : CliktCommand( - help = "Show a QR code pointing to running odoo instances", -) { +) : CliktCommand() { + override fun help(context: Context) = "Show a QR code pointing to running odoo instances" + override fun run() { val interfaces = NetworkInterface.networkInterfaces() .asSequence() diff --git a/actions/src/commands/RestoreCommand.kt b/actions/src/commands/RestoreCommand.kt index d037941..4f7f4ea 100644 --- a/actions/src/commands/RestoreCommand.kt +++ b/actions/src/commands/RestoreCommand.kt @@ -1,6 +1,8 @@ package com.github.hubvd.odootools.actions.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.defaultLazy import com.github.ajalt.clikt.parameters.groups.mutuallyExclusiveOptions @@ -12,7 +14,6 @@ import com.github.ajalt.clikt.parameters.options.validate import com.github.ajalt.clikt.parameters.types.file import com.github.ajalt.mordant.animation.progress.animateOnThread import com.github.ajalt.mordant.animation.progress.execute -import com.github.ajalt.mordant.terminal.Terminal import com.github.ajalt.mordant.widgets.progress.completed import com.github.ajalt.mordant.widgets.progress.progressBar import com.github.ajalt.mordant.widgets.progress.progressBarLayout @@ -52,12 +53,11 @@ sealed class DumpSource { } class RestoreCommand( - private val terminal: Terminal, private val dumpPassword: Secret, private val httpHandler: HttpHandler, -) : CliktCommand( - help = "Restore an odoo database dump, either from a runbot or a zip", -) { +) : CliktCommand() { + override fun help(context: Context) = "Restore an odoo database dump, either from a runbot or a zip" + private val source by mutuallyExclusiveOptions( option("-z", "--zip").file(mustExist = true, canBeFile = true, canBeDir = false) .convert { DumpSource.ZipSource(it) } diff --git a/actions/src/commands/db/BaseCopyCommand.kt b/actions/src/commands/db/BaseCopyCommand.kt index 4770a6e..273bbc5 100644 --- a/actions/src/commands/db/BaseCopyCommand.kt +++ b/actions/src/commands/db/BaseCopyCommand.kt @@ -55,7 +55,7 @@ abstract class BaseCopyCommand( if (instance != null && window != null) { restartOdoo(window, instance) } - if (!terminal.info.interactive) { + if (!terminal.terminalInfo.interactive) { notificationService.info(notificationMessage(database)) } } diff --git a/actions/src/commands/pr/ListCommand.kt b/actions/src/commands/pr/ListCommand.kt index 7f6bd59..8fde8f2 100644 --- a/actions/src/commands/pr/ListCommand.kt +++ b/actions/src/commands/pr/ListCommand.kt @@ -1,8 +1,10 @@ package com.github.hubvd.odootools.actions.commands.pr import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.core.MissingOption import com.github.ajalt.clikt.core.PrintMessage +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.optional import com.github.ajalt.clikt.parameters.options.default @@ -23,9 +25,9 @@ import com.github.ajalt.mordant.widgets.Text import com.github.hubvd.odootools.actions.ActionsConfig import com.github.hubvd.odootools.actions.utils.* -class ListCommand(private val github: GithubClient, private val config: ActionsConfig) : CliktCommand( - help = "List pull requests involved with the selected username", -) { +class ListCommand(private val github: GithubClient, private val config: ActionsConfig) : CliktCommand() { + override fun help(context: Context) = "List pull requests involved with the selected username" + private val closed by option().flag() private val githubUsername by option().defaultLazy { config.githubUsernames[odooUsername] ?: throw MissingOption( diff --git a/actions/src/commands/pr/NewCommand.kt b/actions/src/commands/pr/NewCommand.kt index d738ec4..6365652 100644 --- a/actions/src/commands/pr/NewCommand.kt +++ b/actions/src/commands/pr/NewCommand.kt @@ -3,14 +3,15 @@ package com.github.hubvd.odootools.actions.commands.pr import com.github.ajalt.clikt.core.Abort import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.core.Context import com.github.hubvd.odootools.actions.git.currentRepository import com.github.hubvd.odootools.actions.utils.BrowserService import com.github.hubvd.odootools.workspace.Workspaces import kotlin.io.path.name -class NewCommand(private val workspaces: Workspaces, private val browserService: BrowserService) : CliktCommand( - help = "Create a new pr for the current branch in the working directory", -) { +class NewCommand(private val workspaces: Workspaces, private val browserService: BrowserService) : CliktCommand() { + override fun help(context: Context) = "Create a new pr for the current branch in the working directory" + override fun run() { val workspace = workspaces.current() ?: throw Abort() val repo = workspace.currentRepository() ?: throw Abort() diff --git a/actions/src/commands/pr/PrCommand.kt b/actions/src/commands/pr/PrCommand.kt index 7a463e2..78236c0 100644 --- a/actions/src/commands/pr/PrCommand.kt +++ b/actions/src/commands/pr/PrCommand.kt @@ -1,11 +1,14 @@ package com.github.hubvd.odootools.actions.commands.pr import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.core.NoOpCliktCommand import com.github.ajalt.clikt.core.subcommands import org.kodein.di.* -class PrCommand : NoOpCliktCommand(help = "Work with pull requests") +class PrCommand : NoOpCliktCommand() { + override fun help(context: Context) = "Work with pull requests" +} val PR_COMMAND_MODULE by DI.Module { bindSet(tag = "pr") { diff --git a/actions/src/commands/pycharm/PycharmActions.kt b/actions/src/commands/pycharm/PycharmActions.kt index a24d75a..afff28d 100644 --- a/actions/src/commands/pycharm/PycharmActions.kt +++ b/actions/src/commands/pycharm/PycharmActions.kt @@ -17,7 +17,9 @@ import kotlin.io.path.Path * the following should be put in the Arguments input: * example "$ProjectFileDir$" "$FilePath$" "$LineNumber$" "$ColumnNumber$" $SelectedText$ */ -abstract class BasePycharmAction(name: String? = null) : CliktCommand(name = name, hidden = true) { +abstract class BasePycharmAction(name: String? = null) : CliktCommand(name = name) { + override val hiddenFromHelp = true + protected abstract val workspaces: Workspaces protected val workspace by argument().convert { option -> workspaces.list().first { it.path == Path(option) } } diff --git a/actions/src/commands/repo/RepoCommand.kt b/actions/src/commands/repo/RepoCommand.kt index 3d99d3b..26cd84b 100644 --- a/actions/src/commands/repo/RepoCommand.kt +++ b/actions/src/commands/repo/RepoCommand.kt @@ -2,6 +2,7 @@ package com.github.hubvd.odootools.actions.commands.repo import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.obj import com.github.ajalt.clikt.core.registerCloseable import com.github.ajalt.clikt.core.subcommands import com.github.ajalt.clikt.parameters.options.flag @@ -38,9 +39,9 @@ class WorkspaceRepositories(val workspace: Workspace) : AutoCloseable { class RepoCommand( private val workspaces: Workspaces, -) : CliktCommand( - allowMultipleSubcommands = true, -) { +) : CliktCommand() { + override val allowMultipleSubcommands = true + private val all by option("-a", "--all").flag() override fun run() = runBlocking { diff --git a/buildSrc/src/main/kotlin/CliApplicationPlugin.kt b/buildSrc/src/main/kotlin/CliApplicationPlugin.kt index 32812a7..6ab1f78 100644 --- a/buildSrc/src/main/kotlin/CliApplicationPlugin.kt +++ b/buildSrc/src/main/kotlin/CliApplicationPlugin.kt @@ -2,6 +2,7 @@ import org.graalvm.buildtools.gradle.dsl.GraalVMExtension import org.gradle.api.DefaultTask import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.artifacts.ExternalModuleDependency import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property @@ -25,8 +26,12 @@ class CliApplicationPlugin : Plugin { val libs = project.extensions.getByType().named("libs") project.dependencies { - dependencies.add("implementation", libs.findLibrary("clikt").get()) - dependencies.add("implementation", libs.findLibrary("mordant").get()) + dependencies.add("implementation", libs.findLibrary("clikt").get(), closureOf { + exclude(module = "mordant-jvm-jna") + }) + dependencies.add("implementation", libs.findLibrary("mordant").get(), closureOf { + exclude(module = "mordant-jvm-jna") + }) } this.extension = project.extensions.create("cli") diff --git a/buildSrc/src/main/kotlin/NativeImageConvention.kt b/buildSrc/src/main/kotlin/NativeImageConvention.kt index 9152a49..99ad403 100644 --- a/buildSrc/src/main/kotlin/NativeImageConvention.kt +++ b/buildSrc/src/main/kotlin/NativeImageConvention.kt @@ -25,13 +25,7 @@ class NativeImageConvention : Plugin { } testSupport = true binaries { - val commonFlags = arrayOf( - // FIXME: PR in mordant - "--initialize-at-build-time=com.github.ajalt.mordant.internal.nativeimage.NativeImagePosixMppImpls", - "--initialize-at-build-time=com.github.ajalt.mordant.internal.syscalls.nativeimage.SyscallHandlerNativeImageLinux", - "--initialize-at-build-time=com.github.ajalt.mordant.internal.syscalls.SyscallHandlerPosix\$Companion", - "--initialize-at-build-time=com.github.ajalt.mordant.internal.syscalls.SyscallHandlerPosix\$TermiosConstants", - ) + val commonFlags = arrayOf() named("test") { buildArgs( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ab5c5f6..c48bc73 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,24 +1,23 @@ [versions] -kotlinx-serialization = "1.7.1" +kotlinx-serialization = "1.7.2" kotlin = "2.0.20" [libraries] kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" } -kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } serialization-toml = "com.akuleshov7:ktoml-core:0.5.2" -coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0-RC.2" +coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0" process = "com.github.pgreze:kotlin-process:1.5" xmlbuilder = "org.redundent:kotlin-xml-builder:1.9.1" kodein-di = "org.kodein.di:kodein-di:7.22.0" -http4k-core = "org.http4k:http4k-core:5.29.0.0" -clikt = "com.github.ajalt.clikt:clikt:4.4.0" -mordant = "com.github.ajalt.mordant:mordant:2.7.2" -graalvm-native-buildtools = { module = "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin", version = "0.10.2" } -graalvm-svm = "org.graalvm.nativeimage:svm:24.0.2" +http4k-core = "org.http4k:http4k-core:5.30.1.0" +clikt = "com.github.ajalt.clikt:clikt:5.0.0" +mordant = "com.github.ajalt.mordant:mordant:3.0.0" +graalvm-native-buildtools = { module = "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin", version = "0.10.3" } +graalvm-svm = "org.graalvm.nativeimage:svm:24.1.0" spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "7.0.0.BETA1" } arrow-core = "io.arrow-kt:arrow-core:1.2.3" junit-bom = "org.junit:junit-bom:5.11.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b41..0aaefbc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/odoo/src/Odoo.kt b/odoo/src/Odoo.kt index ec494e2..434adb2 100644 --- a/odoo/src/Odoo.kt +++ b/odoo/src/Odoo.kt @@ -1,6 +1,7 @@ package com.github.hubvd.odootools.odoo import com.github.ajalt.clikt.core.UsageError +import com.github.ajalt.clikt.core.main import com.github.ajalt.clikt.core.subcommands import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.config.CONFIG_MODULE diff --git a/odoo/src/commands/CompleteCommand.kt b/odoo/src/commands/CompleteCommand.kt index 53a33cb..0b8bb09 100644 --- a/odoo/src/commands/CompleteCommand.kt +++ b/odoo/src/commands/CompleteCommand.kt @@ -1,6 +1,7 @@ package com.github.hubvd.odootools.odoo.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.enum @@ -21,15 +22,17 @@ enum class CompletionType { Addon, Qunit, Hoot, TestTag, Lang } @Serializable private data class Ctag(val name: String, val scope: String? = null, val scopeKind: String? = null) -class CompleteCommand(private val workspaces: Workspaces) : CliktCommand(hidden = true) { +class CompleteCommand(private val workspaces: Workspaces) : CliktCommand() { private val token by option(help = "current token").required() private val type by option().enum().required() + override val hiddenFromHelp = true + private lateinit var arguments: List private lateinit var workspace: Workspace override fun run() { - arguments = if (currentContext.terminal.info.inputInteractive) { + arguments = if (currentContext.terminal.terminalInfo.inputInteractive) { emptyList() } else { System.`in`.bufferedReader().use { it.lineSequence().toList() } diff --git a/odoo/src/commands/LaunchCommand.kt b/odoo/src/commands/LaunchCommand.kt index 1bf0e71..d675908 100644 --- a/odoo/src/commands/LaunchCommand.kt +++ b/odoo/src/commands/LaunchCommand.kt @@ -1,6 +1,7 @@ package com.github.hubvd.odootools.odoo.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.multiple import com.github.ajalt.clikt.parameters.options.Option @@ -15,11 +16,9 @@ class LaunchCommand( private val workspaces: Workspaces, private val actionProvider: ActionProvider, private val config: WorkspaceConfig, -) : CliktCommand( - treatUnknownOptionsAsArgs = true, - invokeWithoutSubcommand = true, - name = "odoo", -) { +) : CliktCommand(name = "odoo") { + override val invokeWithoutSubcommand = true + override val treatUnknownOptionsAsArgs = true private val ignores = HashSet() diff --git a/odoo/test/commands/LaunchCommandTest.kt b/odoo/test/commands/LaunchCommandTest.kt index 516baad..7f7c12b 100644 --- a/odoo/test/commands/LaunchCommandTest.kt +++ b/odoo/test/commands/LaunchCommandTest.kt @@ -5,6 +5,7 @@ import assertk.assertions.containsExactlyInAnyOrder import assertk.assertions.containsOnly import assertk.assertions.isEmpty import assertk.assertions.isEqualTo +import com.github.ajalt.clikt.core.parse import com.github.hubvd.odootools.odoo.ODOO_MODULE import com.github.hubvd.odootools.odoo.RunConfiguration import com.github.hubvd.odootools.odoo.actions.Action diff --git a/worktree/src/Worktree.kt b/worktree/src/Worktree.kt index db06a8f..80842da 100644 --- a/worktree/src/Worktree.kt +++ b/worktree/src/Worktree.kt @@ -2,6 +2,7 @@ package com.github.hubvd.odootools.worktree import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.NoOpCliktCommand +import com.github.ajalt.clikt.core.main import com.github.ajalt.clikt.core.subcommands import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.config.CONFIG_MODULE diff --git a/worktree/src/commands/AddCommand.kt b/worktree/src/commands/AddCommand.kt index 49c9c66..13a6660 100644 --- a/worktree/src/commands/AddCommand.kt +++ b/worktree/src/commands/AddCommand.kt @@ -3,11 +3,11 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.completion.CompletionCandidates.Custom.Companion.fromStdout import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.options.* import com.github.ajalt.clikt.parameters.types.path import com.github.ajalt.mordant.rendering.TextColors import com.github.ajalt.mordant.rendering.TextStyles -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.workspace.Workspace import com.github.hubvd.odootools.workspace.WorkspaceConfig import com.github.hubvd.odootools.workspace.Workspaces @@ -18,8 +18,7 @@ import kotlin.io.path.div import kotlin.io.path.exists class AddCommand( - private val config: WorkspaceConfig, - private val terminal: Terminal, + config: WorkspaceConfig, private val workspaces: Workspaces, private val stubs: OdooStubs, private val venvs: Virtualenvs, @@ -44,6 +43,7 @@ class AddCommand( override val base: String get() = this@AddCommand.base } + val terminal = terminal processSequence(terminal) { cd(path) createGitWorktrees( diff --git a/worktree/src/commands/CurrentCommand.kt b/worktree/src/commands/CurrentCommand.kt index f8f6a65..231d356 100644 --- a/worktree/src/commands/CurrentCommand.kt +++ b/worktree/src/commands/CurrentCommand.kt @@ -1,16 +1,16 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.default import com.github.ajalt.clikt.parameters.types.enum -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.workspace.WorkspaceFormat import com.github.hubvd.odootools.workspace.Workspaces import com.github.hubvd.odootools.workspace.format import kotlin.system.exitProcess -class CurrentCommand(private val terminal: Terminal, private val workspaces: Workspaces) : CliktCommand() { +class CurrentCommand(private val workspaces: Workspaces) : CliktCommand() { private val format by argument().enum().default(WorkspaceFormat.Json) override fun run() { diff --git a/worktree/src/commands/DefaultCommand.kt b/worktree/src/commands/DefaultCommand.kt index 2c3ab67..e8d22e8 100644 --- a/worktree/src/commands/DefaultCommand.kt +++ b/worktree/src/commands/DefaultCommand.kt @@ -1,15 +1,15 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.default import com.github.ajalt.clikt.parameters.types.enum -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.workspace.WorkspaceFormat import com.github.hubvd.odootools.workspace.Workspaces import com.github.hubvd.odootools.workspace.format -class DefaultCommand(private val terminal: Terminal, private val workspaces: Workspaces) : CliktCommand() { +class DefaultCommand(private val workspaces: Workspaces) : CliktCommand() { private val format by argument().enum().default(WorkspaceFormat.Json) override fun run() { diff --git a/worktree/src/commands/ListCommand.kt b/worktree/src/commands/ListCommand.kt index 49de0a1..4c66ccb 100644 --- a/worktree/src/commands/ListCommand.kt +++ b/worktree/src/commands/ListCommand.kt @@ -1,6 +1,7 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.optional import com.github.ajalt.clikt.parameters.types.enum @@ -8,16 +9,16 @@ import com.github.ajalt.mordant.rendering.TextColors import com.github.ajalt.mordant.rendering.TextStyles import com.github.ajalt.mordant.table.Borders import com.github.ajalt.mordant.table.table -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.workspace.WorkspaceFormat import com.github.hubvd.odootools.workspace.Workspaces import com.github.hubvd.odootools.workspace.format -class ListCommand(private val workspaces: Workspaces, private val terminal: Terminal) : CliktCommand() { +class ListCommand(private val workspaces: Workspaces) : CliktCommand() { private val format by argument().enum().optional() override fun run() { + val terminal = terminal val workspaces = workspaces.list() - if (terminal.info.outputInteractive && format == null) { + if (terminal.terminalInfo.outputInteractive && format == null) { terminal.println( table { tableBorders = Borders.ALL diff --git a/worktree/src/commands/PruneCommand.kt b/worktree/src/commands/PruneCommand.kt index ed7f14c..00a359e 100644 --- a/worktree/src/commands/PruneCommand.kt +++ b/worktree/src/commands/PruneCommand.kt @@ -1,14 +1,13 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.mordant.terminal.Terminal +import com.github.ajalt.clikt.core.terminal import com.github.hubvd.odootools.workspace.Workspaces import com.github.hubvd.odootools.worktree.processSequence import com.github.hubvd.odootools.worktree.pruneGitWorktrees class PruneCommand( private val workspaces: Workspaces, - private val terminal: Terminal, ) : CliktCommand() { override fun run() { processSequence(terminal) { diff --git a/worktree/src/commands/RebuildCommand.kt b/worktree/src/commands/RebuildCommand.kt index fd534b4..e1b3fa6 100644 --- a/worktree/src/commands/RebuildCommand.kt +++ b/worktree/src/commands/RebuildCommand.kt @@ -2,9 +2,9 @@ package com.github.hubvd.odootools.worktree.commands import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktError +import com.github.ajalt.clikt.core.terminal import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.mordant.terminal.Terminal import com.github.hubvd.odootools.workspace.Workspaces import com.github.hubvd.odootools.worktree.OdooStubs import com.github.hubvd.odootools.worktree.Pycharm @@ -12,7 +12,6 @@ import com.github.hubvd.odootools.worktree.Virtualenvs import com.github.hubvd.odootools.worktree.processSequence class RebuildCommand( - private val terminal: Terminal, private val workspaces: Workspaces, private val stubs: OdooStubs, private val venvs: Virtualenvs,