libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit a479803c7baad97f5f6ca68f14d7fe2e5b3eae94
parent 1d4a535ef39046dc4ee814966eff145778adc81b
Author: Antoine A <>
Date:   Fri, 24 Jan 2025 13:52:19 +0100

nexus: table list format replaced by a multiline format that works better with narrow terminals

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt | 73++++++++++++++++++++++++++++++-------------------------------------------
1 file changed, 30 insertions(+), 43 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt @@ -212,7 +212,7 @@ class ListCmd: CliktCommand("list") { override fun run() = cliCmd(logger, common.log) { nexusConfig(common.config).withDb { db, cfg -> - fun fmtPayto(payto: String?): String { + fun fmtPayto(payto: String): String { if (payto == null) return "" try { val parsed = Payto.parse(payto).expectIban() @@ -225,61 +225,48 @@ class ListCmd: CliktCommand("list") { return payto.removePrefix("payto://") } } - val (columnNames, rows) = when (kind) { + when (kind) { ListKind.incoming -> { val txs = db.list.incoming() - Pair( - listOf( - "transaction", "id", "talerable", "debtor", "subject" - ), - txs.map { - listOf( - "${it.date} ${it.amount}", - it.id.toString(), - it.talerable?.toString() ?: "", - fmtPayto(it.debtor), - it.subject - ) + for (tx in txs) { + println("${tx.date} ${tx.id} ${tx.amount}") + println(" debtor: ${fmtPayto(tx.debtor)}") + println(" subject: ${tx.subject}") + if (tx.talerable != null) { + println(" talerable: ${tx.talerable}") } - ) + println() + } } ListKind.outgoing -> { val txs = db.list.outgoing() - Pair( - listOf( - "transaction", "id", "creditor", "talerable", "subject" - ), - txs.map { - listOf( - "${it.date} ${it.amount}", - it.id, - fmtPayto(it.creditor), - "${it.wtid?.toString() ?: ""} ${it.exchangeBaseUrl ?: ""}", - it.subject ?: "", - ) + for (tx in txs) { + println("${tx.date} ${tx.id} ${tx.amount}") + if (tx.creditor != null) { + println(" creditor: ${fmtPayto(tx.creditor)}") + } + println(" subject: ${tx.subject}") + if (tx.wtid != null) { + println(" talerable: ${tx.wtid} ${tx.exchangeBaseUrl}") } - ) + println() + } } ListKind.initiated -> { val txs = db.list.initiated() - Pair( - listOf( - "transaction", "id", "submission", "creditor", "status", "subject" - ), - txs.map { - listOf( - "${it.date} ${it.amount}", - "${it.batch ?: "<batch>"}.${it.id}", - "${it.submissionTime} ${it.submissionCounter}", - fmtPayto(it.creditor), - "${it.status} ${it.msg ?: ""}".trim(), - it.subject - ) + for (tx in txs) { + println("${tx.date} ${tx.id} ${tx.amount}") + println(" creditor: ${fmtPayto(tx.creditor)}") + println(" subject: ${tx.subject}") + if (tx.batch != null) { + println(" batch: ${tx.batch}") } - ) + println(" submission: ${tx.submissionTime} ${tx.submissionCounter}") + println(" status: ${tx.status} ${tx.msg ?: ""}") + println() + } } } - printTable(columnNames, rows) } } }