Total Complexity | 4 |
Complexity/F | 0 |
Lines of Code | 57 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Command } from 'commander' |
||
2 | import app from './app' |
||
3 | |||
4 | const start = async (): Promise<void> => { |
||
5 | const program = new Command() |
||
6 | |||
7 | program. |
||
8 | on('--help', () => { |
||
9 | console.log('') |
||
10 | console.log(` |
||
11 | Usage: node index.js -f elmo |
||
12 | node index.js -l |
||
13 | node index.js -c |
||
14 | `) |
||
15 | }). |
||
16 | option('-f --find <wallet>', 'Find Wallet from LevelDB'). |
||
17 | option('-l --list', 'Find Wallet List from LevelDB'). |
||
18 | option('-c --count', 'View Number of wallets in LevelDB'). |
||
19 | parse(process.argv) |
||
20 | |||
21 | const { |
||
22 | find, |
||
23 | list, |
||
24 | count, |
||
25 | } = program |
||
26 | |||
27 | let query: { |
||
28 | command?: string |
||
29 | arg?: string |
||
30 | } = {} |
||
31 | |||
32 | if (find) { |
||
33 | query.command = 'f' |
||
34 | query.arg = find |
||
35 | } |
||
36 | if (list) { |
||
37 | query.command = 'l' |
||
38 | } |
||
39 | if (count) { |
||
40 | query.command = 'c' |
||
41 | } |
||
42 | if (!query.command) { |
||
43 | console.log(` |
||
44 | arguments are required. |
||
45 | Usage: node index.js -f [target] -> Find target Wallet |
||
46 | node index.js -l -> View List of Wallet |
||
47 | node index.js -c -> Show Number of Wallets |
||
48 | help: node index.js --help |
||
49 | `) |
||
50 | return |
||
51 | } |
||
52 | |||
53 | return await app(query) |
||
54 | } |
||
55 | |||
56 | start().catch(e => console.error(e)) |
||
57 |