-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcli.js
44 lines (37 loc) · 1.17 KB
/
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
38
39
40
41
42
43
44
'use strict';
const React = require('react');
const { setCurrentCXT } = require('./src/utils/utils');
const importJsx = require('import-jsx');
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, isGlobal: true });
// Show update notification
notifier.notify();
cli.version(pkg.version, '-v, --version');
cli
.command('get <resource>')
.option('--context <name>', 'set kubernetes context to use')
.description('get live update on the <resource>')
.action((resource, args) => {
commandMatched = true;
if (args.context) {
setCurrentCXT(args.context);
}
const App = importJsx('./src/containers/app');
render(<App resource={resource} />);
});
cli.parse(process.argv);
// hack to render default resource if nothing was given
if (process.argv.length === 2) {
commandMatched = true;
const App = importJsx('./src/containers/app');
render(<App resource={defaultResource} />);
}
if (!commandMatched) {
cli.help();
}