Skip to content

Commit

Permalink
add list filters
Browse files Browse the repository at this point in the history
  • Loading branch information
kajoseph committed Jan 3, 2024
1 parent 2d55445 commit eedcb3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/bitcore-client/bin/wallet-list
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ const { Storage } = require('../ts_build/src/storage');

program
.version(require('../package.json').version)
.option('--chain <chain>', 'optional - filter the wallets by chain')
.option('--network <network>', 'optional - filter the wallets by network')
.option('--storageType <storageType>', 'optional - default Level - choose the database from where to list wallets')
.option('--path <path>', 'optional - Where wallets are stored')
.parse(process.argv);

const main = async () => {
const { path, storageType } = program.opts();
const { path, storageType, chain: chainParam, network: networkParam } = program.opts();
const storage = new Storage({createIfMissing: false, errorIfExists: false, path, storageType});
const walletStream = await storage.listWallets();
walletStream.on('data', (wallet) => {
const { name, chain, network, baseUrl, storageType } = JSON.parse(wallet.toString());
console.log({name, chain, network, baseUrl, storageType});
if (chainParam && chainParam.toUpperCase() !== chain.toUpperCase()) return;
if (networkParam && networkParam.toUpperCase() !== network.toUpperCase()) return;
console.log({ name, chain, network, baseUrl, storageType });
});
};

Expand Down

0 comments on commit eedcb3a

Please sign in to comment.