[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Version file and Sandbox version optio
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Version file and Sandbox version option |
Date: |
Tue, 19 Jan 2021 18:50:05 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 11b4850 Version file and Sandbox version option
11b4850 is described below
commit 11b48501f8ac52d41510b79c893f5c2af075f07a
Author: MS <ms@taler.net>
AuthorDate: Tue Jan 19 18:49:56 2021 +0100
Version file and Sandbox version option
---
build.gradle | 9 +++++++
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 29 ++++++++++++++++------
util/src/main/kotlin/Config.kt | 6 +++++
3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/build.gradle b/build.gradle
index 3d49283..289160d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,16 @@ idea {
setVersion("0.0.1-dev.1")
+task versionFiles() {
+ new File("util/src/main/resources/version.txt").text =
getRootProject().version
+}
+
+classes {
+ dependsOn versionFiles
+}
+
task dist(type: Zip) {
+ dependsOn versionFiles
evaluationDependsOn("nexus")
evaluationDependsOn("sandbox")
def topDir = "${getRootProject().name}-${getRootProject().version}"
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index dedcee6..7719c5c 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -60,6 +60,7 @@ import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.output.CliktHelpFormatter
import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.int
import execThrowableOrTerminate
@@ -80,6 +81,7 @@ import tech.libeufin.util.ebics_h004.EbicsResponse
import tech.libeufin.util.ebics_h004.EbicsTypes
import java.util.*
import kotlin.random.Random
+import kotlin.system.exitProcess
const val DEFAULT_DB_CONNECTION = "jdbc:sqlite:/tmp/libeufin-sandbox.sqlite3"
@@ -95,10 +97,6 @@ data class SandboxError(val statusCode: HttpStatusCode, val
reason: String) : Ex
data class SandboxErrorJson(val error: SandboxErrorDetailJson)
data class SandboxErrorDetailJson(val type: String, val description: String)
-class SandboxCommand : CliktCommand() {
- override fun run() = Unit
-}
-
class ResetTables : CliktCommand("Drop all the tables from the database") {
init {
context {
@@ -193,10 +191,27 @@ fun ensureNonNull(param: String?): String {
)
}
+class SandboxCommand : CliktCommand(invokeWithoutSubcommand = true,
printHelpOnEmptyArgs = true) {
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
+ private val version by option().flag()
+ override fun run() {
+ if (version) {
+ println(getVersion())
+ exitProcess(0)
+ }
+ if (currentContext.invokedSubcommand == null) {
+ println("Caught you: no command was run")
+ }
+ }
+}
+
+
fun main(args: Array<String>) {
- SandboxCommand()
- .subcommands(Serve(), ResetTables())
- .main(args)
+ SandboxCommand().subcommands(Serve(), ResetTables()).main(args)
}
fun serverMain(dbName: String, port: Int) {
diff --git a/util/src/main/kotlin/Config.kt b/util/src/main/kotlin/Config.kt
index 607ac67..2788cdf 100644
--- a/util/src/main/kotlin/Config.kt
+++ b/util/src/main/kotlin/Config.kt
@@ -6,6 +6,12 @@ import ch.qos.logback.classic.util.ContextInitializer
import ch.qos.logback.core.util.Loader
import org.slf4j.LoggerFactory
+fun getVersion(): String {
+ return Loader.getResource(
+ "version.txt", ClassLoader.getSystemClassLoader()
+ ).readText()
+}
+
/**
* Set system properties to wanted values, and load logback configuration
after.
* While it can set any system property, it is used only to set the log file
name.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Version file and Sandbox version option,
gnunet <=