Skip to Content
Learning Node.js Development
book

Learning Node.js Development

by Andrew Mead
January 2018
Beginner
658 pages
13h 10m
English
Packt Publishing
Content preview from Learning Node.js Development

Using chaining syntax on yargs

Now in order to get started, we need to make some changes inside of app.js. We're going to start with the add command (for more information, please refer to the Adding and saving notes section in the previous chapter).

We want to add a few helpful pieces of information in argv function inside app.js, that will:

  • Let yargs verify the add command is ran appropriately, and
  • Let the user know how the add command is meant to be executed

Now we are going to be chaining property calls, which means right before I access .argv I want to call .command, and then I'll call .argv on the return value from command as shown here:

const argv = yargs  .command()  .argv;

Now this chaining syntax probably looks familiar if you've ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Node.js Development

Advanced Node.js Development

Andrew Mead
Node.js: Tools & Skills, 2nd Edition

Node.js: Tools & Skills, 2nd Edition

James Hibbard, Michael Wanyoike, Nilson Jacques, Jay Raj, Manjunath M
Your First Week With Node.js, 2nd Edition

Your First Week With Node.js, 2nd Edition

James Hibbard, Craig Buckler, Mark Brown, Nilson Jacques, James Kolce, Paul Orac, M. David Green, Florian Rappl

Publisher Resources

ISBN: 9781788395540Supplemental Content