forked from ameerthehacker/kubelive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
37 lines (31 loc) · 931 Bytes
/
cli.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
'use strict';
const React = require('react');
const importJsx = require('import-jsx');
const App = importJsx('./containers/app');
const { render } = require('ink');
const cli = require('commander');
const pkg = require('./package.json');
const defaultResource = 'pods';
let commandMatched = false;
const updateNotifier = require('update-notifier');
// Checking for available updates
const notifier = updateNotifier({ pkg });
// Show update notification
notifier.notify();
// hack to render default resource if nothing was given
if (process.argv.length == 2) {
commandMatched = true;
render(<App resource={defaultResource} />);
}
cli.version(pkg.version, '-v, --version');
cli
.command('get <resource>')
.description('get live update on the <resource>')
.action((resource) => {
commandMatched = true;
render(<App resource={resource} />);
});
cli.parse(process.argv);
if (!commandMatched) {
cli.help();
}