forked from yerofey/cryptowallet-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
44 lines (36 loc) · 1.51 KB
/
cli.js
File metadata and controls
44 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
'use strict';
const { program } = require('commander');
const chalk = require('chalk');
const { log, supportedCoins } = require('./src/utils');
const Method = require('./src/Method');
program.option('-c, --coin <ticker>', 'Wallet for specific coin', 'ERC');
program.option('-f, --format <format>', 'Wallet format type (for cryptos with multiple wallet formats)');
program.option('-g, --geek', 'Display some more info (geeky)');
program.option('-l, --list', 'List all supported cryptos');
program.option('-m, --mnemonic [mnemonic]', 'Generate wallet from mnemonic string OR just a mnemonic string');
program.option('-n, --number <number>', 'Number of wallets to generate (if supported)');
program.option('-p, --prefix <prefix>', 'Desired wallet prefix (case sensitive)');
program.option('-P, --prefix-ignorecase <prefix>', 'Desired wallet prefix (case insensitive)');
program.option('-v, --version', 'Display cryptowallet version');
program.parse();
(async () => {
const options = program.opts();
if (options.list !== undefined) {
return new Method('list').init();
}
if (options.mnemonic == true) {
return new Method('mnemonic').init();
}
if (options.version) {
return new Method('version').init();
}
const coin = (options.coin).toUpperCase() || '';
if (supportedCoins.includes(coin)) {
return new Method('wallet', {
coin,
options
}).init();
}
log(chalk.red('⛔️ Error: coin not supported!'));
})();