aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-11-15 15:52:33 +0100
committerMS <ms@taler.net>2023-11-15 15:52:33 +0100
commitc8ee59217de3af90dae76baf5563e9b77a99d623 (patch)
tree816625c37a0cf3e50c5923fb967495bf2ad42bb3
parenta6be569fb2f008766e02bd62ce82a4f44025f05b (diff)
downloadlibeufin-c8ee59217de3af90dae76baf5563e9b77a99d623.tar.gz
libeufin-c8ee59217de3af90dae76baf5563e9b77a99d623.tar.bz2
libeufin-c8ee59217de3af90dae76baf5563e9b77a99d623.zip
nexus: adding --debug to read from STDIN
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt11
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt10
2 files changed, 14 insertions, 7 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
index f4cd09d6..fe31ea50 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
@@ -482,6 +482,12 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti
" latest document is always until the current time."
)
+ private val debug by option(
+ help = "Reads one ISO20022 document from STDIN and prints " +
+ "the parsing results. It does not affect the database."
+ ).flag(default = false)
+
+
/**
* This function collects the main steps of fetching banking records.
* In this current version, it does not implement long polling, instead
@@ -515,10 +521,9 @@ class EbicsFetch: CliktCommand("Fetches bank records. Defaults to camt.054 noti
if (onlyStatements) whichDoc = SupportedDocument.CAMT_053
if (onlyLogs) whichDoc = SupportedDocument.PAIN_002_LOGS
- // If STDIN has data, we run in debug mode: parse, print, and return.
- val maybeStdin = generateSequence(::readLine).joinToString("\n")
- if (maybeStdin.isNotEmpty()) {
+ if (debug) {
logger.debug("Reading from STDIN, running in debug mode. Not involving the database.")
+ val maybeStdin = generateSequence(::readLine).joinToString("\n")
when(whichDoc) {
SupportedDocument.CAMT_054 -> {
val incoming = findIncomingTxInNotification(maybeStdin, cfg.currency)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt
index ab92cc09..47a895d8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsSubmit.kt
@@ -229,6 +229,9 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat
"ignoring the 'frequency' configuration value"
).flag(default = false)
+ private val debug by option(
+ help = "Reads the pain.001 document from STDIN and submits it to the bank"
+ ).flag(default = false)
/**
* Submits any initiated payment that was not submitted
* so far and -- according to the configuration -- returns
@@ -259,10 +262,9 @@ class EbicsSubmit : CliktCommand("Submits any initiated payment found in the dat
clientPrivateKeysFile = clientKeys,
httpClient = HttpClient()
)
- // If STDIN has data, we run in debug mode: submit and return.
- val maybeStdin = generateSequence(::readLine).joinToString("\n")
- if (maybeStdin.isNotEmpty()) {
- logger.info("Submitting STDIN to the bank")
+ if (debug) {
+ logger.info("Running in debug mode, submitting STDIN to the bank")
+ val maybeStdin = generateSequence(::readLine).joinToString("\n")
doOrFail {
runBlocking {
submitPain001(