-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (59 loc) · 1.57 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
import init from './lib/init.js';
import cli from './lib/cli.js';
import getCommunityArticles from './lib/utils/handlers/getCommunityArticles.js';
import getLatestArticles from './lib/utils/handlers/getLatestArticles.js';
import getTrendingArticles from './lib/utils/handlers/getTrendingArticles.js';
import getArticlesByUser from './lib/utils/handlers/getArticlesByUser.js';
import getFeaturedArticles from './lib/utils/handlers/getFeaturedArticles.js';
import inquirer from 'inquirer';
const input = cli.input;
const flags = cli.flags;
const { latest, featured, user, trending, community, debug, clear } = flags;
(async () => {
{clear && console.clear()}
if (
(latest, featured, user, trending, community, debug === false) &&
!input.includes(`articles`)
) {
init();
}
input.includes(`help`) && cli.showHelp(0);
{
community && input.includes(`articles`) && getCommunityArticles();
}
{
latest && input.includes(`articles`) && getLatestArticles();
}
{
featured && input.includes(`articles`) && getFeaturedArticles();
}
{
user &&
input.includes(`articles`) &&
inquirer
.prompt([
{
name: 'username',
message:
'Enter the Hashnode username you want to filter by:'
}
])
.then(answers => {
getArticlesByUser(answers.username);
})
.catch(error => {
if (error.isTtyError) {
console.log('typeError');
} else {
console.log('something wen wrong');
}
});
}
{
trending && input.includes(`articles`) && getTrendingArticles();
}
{
debug && console.log(cli.flags);
}
})();