Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 27 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 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 |