-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·73 lines (67 loc) · 1.7 KB
/
app.js
File metadata and controls
executable file
·73 lines (67 loc) · 1.7 KB
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
65
66
67
68
69
70
71
72
73
// const fs = require('fs');
const chalk = require('chalk');
const yargs = require('yargs');
const utils = require('./utils')
// console.log(chalk.red("Hello"))
// yargs command for 'add' command to add new note
yargs.command({
command: 'add',
describe: 'Add new note',
handler: function(argv) {
console.log(chalk.blue.bold("Adding new note..."));
utils.addNote(argv.title, argv.body);
},
builder: {
title: {
describe: 'Title of the new note',
demandOption: true,
type: 'string'
},
body: {
describe: 'Body of the new note',
demandOption: true,
type: 'string'
}
}
})
// yargs command for 'list' command to list all existing notes
yargs.command({
command: 'list',
describe: 'List all notes',
handler: function() {
// console.log("Listing all notes...");
utils.listNotes();
}
})
// yargs command for 'remove' command to remove a note
yargs.command({
command: 'remove',
describe: 'Remove a note',
handler: function(argv) {
utils.removeNote(argv.title);
},
builder: {
title: {
describe: "Title of the note to be removed",
demandOption: true,
type: 'string'
}
}
})
// yargs command for 'read' command to read a note in detail
yargs.command({
command: 'read',
describe: 'Read a note in detail',
handler: function(argv) {
utils.readNote(argv.title);
},
builder: {
title: {
describe: "Title of the note you want to read",
demandOption: true,
type: 'string'
}
}
})
// parse yargs commands
yargs.parse();