January 2018
Beginner
658 pages
13h 10m
English
Now, since the read command is working, we can move on to the last one, which is the remove command. Here, I'll call notes.removeNote, passing in the title, which as we know is available in argv.title:
console.log('Starting app.js');const fs = require('fs');const _ = require('lodash');const yargs = require('yargs');const notes = require('./notes.js');const argv = yargs.argv;var command = process.argv[2];console.log('Command:', command);console.log('Yargs', argv);if (command === 'add') { notes.addNote(argv.title, argv.body);} else if (command === 'list') { notes.getAll();} else if (command === 'read') { notes.getNote(argv.title);} else if (command === 'remove') { notes.removeNote(argv.title);} else { console.log('Command ...Read now
Unlock full access