Passed
Push — main ( c69931...d5b3a6 )
by Dylan
04:32
created

src/cli.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 27
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
dl 0
loc 27
c 0
b 0
f 0
rs 10
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 0
1
#!/usr/bin/env node
2
import beepody from './'
3
4
// if there are args, evaluate as an expression and return the result
5
if (process.argv.length > 2) {
6
  const engine = process.argv.shift()
7
  void engine
8
  const script = process.argv.shift()
9
  void script
10
  const input = process.argv.join(' ')
11
  // process.stdout.write(beepody.evaluate(input))
12
  process.stdout.write(input)
13
}
14
// otherwise, prompt for expressions to evaluate
15
else {
16
  console.log(`beepody v${beepody.version}`)
17
  const prompt = 'beepody> '
18
  const stdin = process.openStdin()
19
  stdin.setEncoding('utf8')
20
  process.stdout.write(prompt)
21
  stdin.on('data', function (result: string) {
22
    // process.stdout.write(beepody.evaluate(result.trim()))
23
    process.stdout.write(result.trim())
24
    process.stdout.write(prompt)
25
  })
26
}
27