-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·41 lines (32 loc) · 893 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
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const isUrl = require('is-url');
const pkg = require('./package.json');
const booom = require('./');
const cli = meow(`
Usage:
$ ${pkg.name} <url>
Options:
--help Show information
--version Show current version
<url> should be a .zip file
Example:
$ ${pkg.name} https://github.com/andreruffert/booom-initial-standard/archive/master.zip
`);
const args = cli.input.reduce((parsedArgs, arg) => {
parsedArgs.url = isUrl(arg) && arg;
return parsedArgs;
}, {});
if (!Object.keys(args).length) {
console.error(`
🔥 ${pkg.name}: missing argument after \`${pkg.name}\`
🔥 ${pkg.name}: Try \`${pkg.name} --help\` for more information.
`);
process.exit(1);
}
if (!args.url) {
console.error(`🔥 ${pkg.name}: You need to specify a URL`);
process.exit(1);
}
booom(args.url);