January 2018
Beginner
658 pages
13h 10m
English
When the read command is used, we want to call notes.getNote, passing in title. Now, title will get passed in and parsed using yargs, which means that we can use argv.title to fetch it. And that's all we have to do when it comes to calling the function:
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') { console.log('Removing ...Read now
Unlock full access