-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·39 lines (37 loc) · 1.03 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
#!/usr/bin/env node
const inquirer = require('inquirer');
const createBookmark = require('./functions/createBookmark');
const getBookmarks = require('./functions/getBookmarks');
async function decideEvent() {
const answer = await inquirer.prompt([
{
type: 'list',
name: 'type',
message: 'what do you wanna do?',
choices: ['create a bookmark', 'list bookmarks', 'quit'],
},
]);
const event = await answer.type;
if (event === 'create a bookmark') {
const bookmark = await inquirer.prompt([
{
type: 'input',
name: 'title',
message: 'Enter the title of yor bookmark',
},
{
type: 'input',
name: 'url',
message: 'Enter the url of yor bookmark',
},
]);
const createdBookmark = await createBookmark(bookmark.title, bookmark.url);
console.log(createdBookmark);
} else if (event === 'list bookmarks') {
const bookmarks = await getBookmarks();
console.log(bookmarks);
} else {
console.log('byeee!!!');
}
}
decideEvent();