aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-16 20:15:55 +0200
committerFlorian Dold <florian@dold.me>2022-10-16 20:15:55 +0200
commit8d4a7d6103032a85c81240d9fb0de32dd44ec435 (patch)
treea0cee947a7b39b9a407f3094bede4e7e9908140f /packages/taler-wallet-cli
parentfbb7dd9e7e7fe4cf0611f5827f0bd250634dc29f (diff)
wallet-core: CLI improvements, ToS fetching fixes
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/index.ts109
1 files changed, 60 insertions, 49 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 249198e3c..b50e11883 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -314,48 +314,42 @@ walletCli
logger.info("finished handling API request");
});
-walletCli
- .subcommand("", "pending", { help: "Show pending operations." })
- .action(async (args) => {
- await withWallet(args, async (wallet) => {
- const pending = await wallet.client.call(
- WalletApiOperation.GetPendingOperations,
- {},
- );
- console.log(JSON.stringify(pending, undefined, 2));
- });
- });
-
-walletCli
- .subcommand("transactions", "transactions", { help: "Show transactions." })
+const transactionsCli = walletCli
+ .subcommand("transactions", "transactions", { help: "Manage transactions." })
.maybeOption("currency", ["--currency"], clk.STRING)
- .maybeOption("search", ["--search"], clk.STRING)
- .action(async (args) => {
- await withWallet(args, async (wallet) => {
- const pending = await wallet.client.call(
- WalletApiOperation.GetTransactions,
- {
- currency: args.transactions.currency,
- search: args.transactions.search,
- },
- );
- console.log(JSON.stringify(pending, undefined, 2));
- });
+ .maybeOption("search", ["--search"], clk.STRING);
+
+// Default action
+transactionsCli.action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const pending = await wallet.client.call(
+ WalletApiOperation.GetTransactions,
+ {
+ currency: args.transactions.currency,
+ search: args.transactions.search,
+ },
+ );
+ console.log(JSON.stringify(pending, undefined, 2));
});
+});
-walletCli
- .subcommand("runPendingOpt", "run-pending", {
- help: "Run pending operations.",
+transactionsCli
+ .subcommand("deleteTransaction", "delete", {
+ help: "Permanently delete a transaction from the transaction list.",
+ })
+ .requiredArgument("transactionId", clk.STRING, {
+ help: "Identifier of the transaction to delete",
})
- .flag("forceNow", ["-f", "--force-now"])
.action(async (args) => {
await withWallet(args, async (wallet) => {
- await wallet.ws.runPending(args.runPendingOpt.forceNow);
+ await wallet.client.call(WalletApiOperation.DeleteTransaction, {
+ transactionId: args.deleteTransaction.transactionId,
+ });
});
});
-walletCli
- .subcommand("retryTransaction", "retry-transaction", {
+transactionsCli
+ .subcommand("retryTransaction", "retry", {
help: "Retry a transaction.",
})
.requiredArgument("transactionId", clk.STRING)
@@ -388,21 +382,6 @@ walletCli
});
walletCli
- .subcommand("deleteTransaction", "delete-transaction", {
- help: "Permanently delete a transaction from the transaction list.",
- })
- .requiredArgument("transactionId", clk.STRING, {
- help: "Identifier of the transaction to delete",
- })
- .action(async (args) => {
- await withWallet(args, async (wallet) => {
- await wallet.client.call(WalletApiOperation.DeleteTransaction, {
- transactionId: args.deleteTransaction.transactionId,
- });
- });
- });
-
-walletCli
.subcommand("withdraw", "withdraw", {
help: "Withdraw with a taler://withdraw/ URI",
})
@@ -604,17 +583,26 @@ exchangesCli
exchangesCli
.subcommand("exchangesTosCmd", "tos", {
- help: "Show terms of service.",
+ help: "Show/request terms of service.",
})
.requiredArgument("url", clk.STRING, {
help: "Base URL of the exchange.",
})
+ .maybeOption("contentTypes", ["--content-type"], clk.STRING)
.action(async (args) => {
+ let acceptedFormat: string[] | undefined = undefined;
+ if (args.exchangesTosCmd.contentTypes) {
+ const split = args.exchangesTosCmd.contentTypes
+ .split(",")
+ .map((x) => x.trim());
+ acceptedFormat = split;
+ }
await withWallet(args, async (wallet) => {
const tosResult = await wallet.client.call(
WalletApiOperation.GetExchangeTos,
{
exchangeBaseUrl: args.exchangesTosCmd.url,
+ acceptedFormat,
},
);
console.log(JSON.stringify(tosResult, undefined, 2));
@@ -765,6 +753,29 @@ advancedCli
});
advancedCli
+ .subcommand("runPendingOpt", "run-pending", {
+ help: "Run pending operations.",
+ })
+ .flag("forceNow", ["-f", "--force-now"])
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ await wallet.ws.runPending(args.runPendingOpt.forceNow);
+ });
+ });
+
+advancedCli
+ .subcommand("", "pending", { help: "Show pending operations." })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const pending = await wallet.client.call(
+ WalletApiOperation.GetPendingOperations,
+ {},
+ );
+ console.log(JSON.stringify(pending, undefined, 2));
+ });
+ });
+
+advancedCli
.subcommand("bench1", "bench1", {
help: "Run the 'bench1' benchmark",
})