(line: string)
| 57 | } |
| 58 | |
| 59 | private async processCommand(line: string) { |
| 60 | const args = line.match(/(?:[^\s"]+|"[^"]*")+/g) || []; |
| 61 | |
| 62 | return await yargs(args) |
| 63 | .command( |
| 64 | "use [symbol]", |
| 65 | "select a wallet", |
| 66 | (yargs) => { |
| 67 | yargs.positional("symbol", { |
| 68 | describe: "BTC or RXD or BSV", |
| 69 | type: "string", |
| 70 | }); |
| 71 | }, |
| 72 | (argv) => { |
| 73 | if (argv.symbol) { |
| 74 | this.currentWallet = |
| 75 | this.wallets[argv.symbol as keyof typeof this.wallets]; |
| 76 | console.log(`using ${argv.symbol as string} wallet`); |
| 77 | |
| 78 | this.setPrompt(); |
| 79 | |
| 80 | console.log(Object.keys(this.wallets)); |
| 81 | } |
| 82 | } |
| 83 | ) |
| 84 | .command( |
| 85 | "switch [index]", |
| 86 | "switch account of wallet", |
| 87 | () => {}, |
| 88 | async (argv) => { |
| 89 | if (argv.index !== undefined) { |
| 90 | if (!this.currentWallet) { |
| 91 | console.log("No wallet selected"); |
| 92 | return; |
| 93 | } |
| 94 | const result = this.currentWallet.switchAccount( |
| 95 | argv.index as number |
| 96 | ); |
| 97 | console.log("current account", result); |
| 98 | |
| 99 | this.setPrompt(); |
| 100 | } |
| 101 | } |
| 102 | ) |
| 103 | .command( |
| 104 | "balance", |
| 105 | "Get the balance", |
| 106 | () => {}, |
| 107 | async () => { |
| 108 | if (!this.currentWallet) { |
| 109 | console.log("No wallet selected"); |
| 110 | return; |
| 111 | } |
| 112 | console.log("Balance:", await this.currentWallet.fetchWalletBalace()); |
| 113 | } |
| 114 | ) |
| 115 | .command( |
| 116 | "send [to] [amount]", |
no test coverage detected