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

Printing the address to screen

Now the address is also getting passed through but we don't print it to the screen, so let's do that. Right after the configuration, let's use console.log to print the entire argv variable to the screen. This will include everything that got parsed by yargs:

  .help()  .alias('help', 'h')  .argv;console.log(argv);

Let's go ahead and rerun it in the Terminal, this time passing in an address. I'll use the a flag, and specifying something like 1301 lombard street, closing the quotes, and hitting enter:

node app.js -a '1301 lombard street'

When we do this we get our object, and as shown in the code output, we have 1301 Lombard St, Philadelphia, PA 19147, USA, the plain text address:

In the preceding screenshot, notice ...

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