Passed
Push — master ( 47dd3c...36b76c )
by Sungyub
03:04 queued 18s
created

src/index.ts   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 57
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 36
mnd 4
bc 4
fnc 0
dl 0
loc 57
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 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