forked from sindresorhus/fast-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·53 lines (44 loc) · 984 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const importJsx = require('import-jsx');
const React = require('react');
const {render} = require('ink');
// Note to self: This cannot be ESM until /~https://github.com/vadimdemedes/import-jsx/issues/15 is fixed.
const ui = importJsx('./ui');
const cli = meow(`
Usage
$ fast
$ fast > file
Options
--upload, -u Measure upload speed in addition to download speed
--single-line Reduce spacing and output to a single line
--json JSON output
Examples
$ fast --upload > file && cat file
17 Mbps
4.4 Mbps
$ fast --upload --json
`, {
flags: {
upload: {
type: 'boolean',
alias: 'u'
},
singleLine: {
type: 'boolean'
},
json: {
type: 'boolean'
}
}
});
const main = async () => {
const app = render(React.createElement(ui, {
singleLine: cli.flags.singleLine,
upload: cli.flags.upload,
json: cli.flags.json
}));
await app.waitUntilExit();
};
main();