-
Notifications
You must be signed in to change notification settings - Fork 0
/
todolist.js
45 lines (45 loc) · 1.04 KB
/
todolist.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
import inquirer from "inquirer";
import chalkAnimation from "chalk-animation";
const sleep = () => {
return new Promise((res) => {
setTimeout(res, 3000);
});
};
async function welcome() {
let rainbowTitle = chalkAnimation.rainbow("Welcome to Typescript TODOLIST Made By Shan");
await sleep();
rainbowTitle.stop();
}
await welcome();
const todos = [];
let AddMore = true;
while (AddMore) {
const answers = await inquirer.prompt([
{
type: 'string',
name: 'todo',
message: 'Enter your Todo',
},
{
type: 'confirm',
name: 'addMore',
message: 'Enter your Todo',
default: false,
}
]);
const { todo, addMore } = answers;
AddMore = addMore;
if (todo) {
todos.push(todo);
}
else {
console.info(`Kindly write any input`);
}
}
if (todos.length > 0) {
console.info(`Your todo list:`);
todos.forEach((t) => console.info(t));
}
else {
console.info(`No todos in the list`);
}