Running yargs

Now that we've installed yargs, we can move over into Atom, inside of app.js, and get started with using it. The basics of yargs, the very core of its feature set, is really simple to take advantage of. The first thing we'll do is to require it up, as we did with fs and lodash in the previous chapter. Let's make a constant and call it yargs, setting it equal to require('yargs'), as shown here:

console.log('Starting app.js');const fs = require('fs');const _ = require('lodash');const yargs = require('yargs');const notes = require('./notes.js');var command = process.argv[2];console.log('Command:', command);console.log(process.argv);if (command === 'add') {  console.log('Adding new note');} else if (command === 'list') { console.log('Listing ...

Get Learning Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.