-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·51 lines (43 loc) · 1.09 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
48
49
50
51
#!/usr/bin/env node
'use strict';
// Get the modules
var meow = require('meow');
var chalk = require('chalk');
var _ = require('lodash');
var jbs = require('./');
// Handle the arguments
var cli = meow({
help: [
'',
'Usage:',
' $ jbs <query>',
'',
'Example:',
' $ jbs "wordpress developer"',
' ',
]
});
// Check if a query is supplied
if (!cli.input[0]) {
console.log(cli.help);
process.exit(1);
}
// Call the jbs module
jbs(cli.input[0], cli.flags).then(function(res) {
console.log();
_.forIn(res.data.items, function(val, key) {
var job = {
title: val.title,
url: val.link,
description: val.snippet
};
console.log(chalk.magenta('==> ') + chalk.blue.bold(job.title));
// console.log(chalk.magenta(' > ') + chalk.white(job.description));
console.log(chalk.magenta(' > ') + chalk.white(job.url));
console.log();
});
console.log(chalk.white('---\n'));
console.log(chalk.white(res.url));
console.log();
process.exit(0);
});