-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·47 lines (45 loc) · 1.4 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
45
46
47
#!/usr/bin/env node
'use strict';
var meow = require('meow');
var chalk = require('chalk');
var blahCode = require('blah-code');
var cli = meow([
'Usage',
' $ blah-code [input]',
'',
'Options',
' --encode, -e Returns the blah code representation of the given text input [Default: true]',
' --decode, -d Returns regular text of the given blah code [Default: false]',
' --ooks, -o Uses this weird ape language instead of blah code [Default: false]',
' --help, -h Shows the help',
'',
'Examples',
' $ blah-code "Hi 👻"',
' blaa bluh. blah bleh bluuh. blaah bluh. bluuh bluuh blaah bluuh blaa. bluuh blehh bleeh bleeh blaah',
'',
' $ blah-code "blaa bluh. blah bleh bluuh. blaah bluh. bluuh bluuh blaah bluuh blaa. bluuh blehh bleeh bleeh blaah" --decode',
' Hi 👻'
], {
alias: {
h: 'help',
e: 'encode',
d: 'decode',
o: 'ooks'
}
});
if (cli.input[0] === undefined) {
console.log(chalk.red('I need input. Enter `' + chalk.bold('blah-code --help') + '` if you need assistance.'));
process.exit(1);
} else if (cli.flags.decode) {
if (cli.flags.ooks) {
console.log(chalk.green(blahCode.decode(cli.input[0], 'ooks')));
} else {
console.log(chalk.green(blahCode.decode(cli.input[0])));
}
} else {
if (cli.flags.ooks) { // eslint-disable-line
console.log(chalk.green(blahCode.encode(cli.input[0], 'ooks')));
} else {
console.log(chalk.green(blahCode.encode(cli.input[0])));
}
}