-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
executable file
·55 lines (50 loc) · 1.1 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env node
'use strict';
const term = require('terminal-kit').terminal,
FileHandle = require('./lib/file-handle'),
main = require('./lib/main');
const args = require('minimist')(process.argv, {
boolean: ['s', 'alternate-screen'],
alias: {
s: 'status',
k: 'keys',
c: 'colors',
m: 'marker'
},
default: {
'alternate-screen': true
}
});
if (args._.length < 3) {
console.error('No input file specified.');
process.exit(1);
}
const file = args._[args._.length - 1];
let colors;
if (args.colors === true) {
colors = ['^r', '^y'];
} else if (args.colors) {
colors = args.colors.split(',');
}
let marker = args.marker;
if (!marker && process.platform === 'win32') {
// Windows CMD and PowerShell dosn't support ANSI Inverse.
marker = '^Y';
}
const progArgs = {
status: args.status,
keys: args.keys,
colors: colors,
selectMarker: marker || '^!',
alternateScreen: args['alternate-screen'],
file: new FileHandle(file),
term: term
};
main(progArgs, (err) => {
let status = 0;
if (err) {
console.error(err);
status = 1;
}
process.exit(status);
});