summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech
diff options
context:
space:
mode:
authorAntoine A <>2024-05-06 15:01:27 +0900
committerAntoine A <>2024-05-06 15:01:27 +0900
commit2bc9b85d82aabb656fc9894430eaad53ab22f2ce (patch)
tree7484b307bcf54903d288ab3eacfefdd206b7911b /nexus/src/main/kotlin/tech
parent68ada1b7fb9eaf926c6111d733f97c4100b275b0 (diff)
downloadlibeufin-2bc9b85d82aabb656fc9894430eaad53ab22f2ce.tar.gz
libeufin-2bc9b85d82aabb656fc9894430eaad53ab22f2ce.tar.bz2
libeufin-2bc9b85d82aabb656fc9894430eaad53ab22f2ce.zip
nexus: add dry-run flag to ebics-btd
Diffstat (limited to 'nexus/src/main/kotlin/tech')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt44
1 files changed, 26 insertions, 18 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 466ac476..0907ad7c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -222,6 +222,9 @@ class EbicsDownload: CliktCommand("Perform EBICS requests", name = "ebics-btd")
" to download (only consumed in --transient mode). The" +
" latest document is always until the current time."
)
+ private val dryRun by option().flag()
+
+ class DryRun: Exception()
override fun run() = cliCmd(logger, common.log) {
val cfg = extractEbicsConfig(common.config)
@@ -239,26 +242,31 @@ class EbicsDownload: CliktCommand("Perform EBICS requests", name = "ebics-btd")
}
}
val fileLogger = FileLogger(ebicsLog)
- ebicsDownload(
- client,
- cfg,
- clientKeys,
- bankKeys,
- EbicsOrder.V3(type, name, scope, messageName, messageVersion, container, option),
- pinnedStartArg,
- null
- ) { stream ->
- if (container == "ZIP") {
- val stream = fileLogger.logFetch(stream, false)
- stream.unzipEach { fileName, xmlContent ->
- println(fileName)
- println(xmlContent.readBytes().toString(Charsets.UTF_8))
+ try {
+ ebicsDownload(
+ client,
+ cfg,
+ clientKeys,
+ bankKeys,
+ EbicsOrder.V3(type, name, scope, messageName, messageVersion, container, option),
+ pinnedStartArg,
+ null
+ ) { stream ->
+ if (container == "ZIP") {
+ val stream = fileLogger.logFetch(stream, false)
+ stream.unzipEach { fileName, xmlContent ->
+ println(fileName)
+ println(xmlContent.readBytes().toString(Charsets.UTF_8))
+ }
+ } else {
+ val stream = fileLogger.logFetch(stream, true) // TODO better name
+ println(stream.readBytes().toString(Charsets.UTF_8))
}
- } else {
- val stream = fileLogger.logFetch(stream, true) // TODO better name
- println(stream.readBytes().toString(Charsets.UTF_8))
+ if (dryRun) throw DryRun()
}
- }
+ } catch (e: DryRun) {
+ // We throw DryRun to not consume files while testing
+ }
}
}