From ecc7b5e76edb5f544dcb18990e239f41c229418c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 24 Mar 2020 17:52:39 +0530 Subject: [PATCH] cli parsing --- src/headless/clk.ts | 13 +++++++------ src/headless/taler-wallet-cli.ts | 8 +++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/headless/clk.ts b/src/headless/clk.ts index 8b3808a3a..ab6526f9c 100644 --- a/src/headless/clk.ts +++ b/src/headless/clk.ts @@ -421,6 +421,13 @@ export class CommandGroup { } } + if (parsedArgs[this.argKey].help) { + this.printHelp(progname, parents); + process.exit(0); + throw Error("not reached"); + } + + for (let i = posArgIndex; i < this.arguments.length; i++) { const d = this.arguments[i]; if (d.required) { @@ -456,12 +463,6 @@ export class CommandGroup { } } - if (parsedArgs[this.argKey].help) { - this.printHelp(progname, parents); - process.exit(0); - throw Error("not reached"); - } - if (foundSubcommand) { foundSubcommand.run( progname, diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts index b88023808..416458487 100644 --- a/src/headless/taler-wallet-cli.ts +++ b/src/headless/taler-wallet-cli.ts @@ -504,7 +504,9 @@ testCli }); testCli - .subcommand("testPayCmd", "test-pay", { help: "create contract and pay" }) + .subcommand("testPayCmd", "test-pay", { help: "Create contract and pay." }) + .requiredOption("merchant", ["-m", "--mechant-url"], clk.STRING) + .requiredOption("apikey", ["-k", "--mechant-api-key"], clk.STRING) .requiredOption("amount", ["-a", "--amount"], clk.STRING) .requiredOption("summary", ["-s", "--summary"], clk.STRING, { default: "Test Payment", @@ -513,8 +515,8 @@ testCli const cmdArgs = args.testPayCmd; console.log("creating order"); const merchantBackend = new MerchantBackendConnection( - "https://backend.test.taler.net/", - "sandbox", + args.testPayCmd.merchant, + args.testPayCmd.apikey, ); const orderResp = await merchantBackend.createOrder( cmdArgs.amount,