-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (40 loc) · 1.1 KB
/
index.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
#!/usr/bin/env node
/**
* aman-cli
* Use `aman help` command to see the usage
*
* @author Aman K <https://aman-kumar-singh.vercel.app/>
*/
require('dotenv').config()
const { fetchWeather } = require('./utils/weather');
const { fetchJoke } = require('./utils/joke')
const { fetchQuote } = require('./utils/quote')
const chalk = require('chalk');
const init = require('./utils/init');
const cli = require('./utils/cli');
const log = require('./utils/log');
const input = cli.input;
const flags = cli.flags;
const { clear, debug } = flags;
(async () => {
init({ clear });
input.includes(`help`) && cli.showHelp(0);
debug && log(flags);
if (input[0] === 'joke') {
fetchJoke();
}
else if (input[0] === 'quote') {
try {
let tag = '';
flags.tl ? tag = 'technology' : flags.ws ? tag = 'wisdom' : flags.mv ? tag = 'motivational' : tag = 'science'
tag !== '' ? fetchQuote(tag) : fetchQuote();
} catch (error) {
console.log(error);
}
}
else if(input[0] === 'weather' && input[1]) {
const city = input[1]
const api = 'ea0c508199f0a5aa52d12f76a599b35e'
fetchWeather(city, api);
}
})();