-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (30 loc) · 1.01 KB
/
Copy pathapp.js
File metadata and controls
37 lines (30 loc) · 1.01 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
/*
* Simple program to manage a JSON notes repository based on nodeJS
* It is a command line yargs tool, with simple sintax:
* - add a note: "C:\node app.js add --title='....' --body='...'"
* - get a note: "C:\node app.js add --title='....' "
* - get all notes: "C:\node app.js list "
* - remove all notes: "C:\node app.js remove --title='...' "
*/
console.log('-> Starting the App...');
const fs = require('fs');
const _ = require('lodash');
const yargs = require('yargs');
const notes = require('./notes.js');
//Arg vector collect the prompt arguments
const argv = yargs.argv;
//I need to isolate the value to pass my function
var command = argv._[0];
//I print the command provided
console.log('-> command:',command);
if(command ==='add'){
notes.addNote(argv.title,argv.body);
} else if(command ==='list'){
notes.fetchNotes();
} else if(command ==='get'){
notes.fetchNote(argv.title);
} else if(command ==='remove'){
notes.removeNote(argv.title);
} else{
console.log('Command null or not recognized')
}