What is the use of optimist module in Node.Js

https://github.com/substack/node-optimist

Optimist is a node.js library for option parsing for people who hate option parsing. More specifically, this module is for people who like all the --bells and -whistlz of program usage but think optstrings are a waste of time.

var argv = require('optimist').argv;

if (argv.rif - 5 * argv.xup > 7.138) {
  console.log('Buy more riffiwobbles');
}
else {
  console.log('Sell the xupptumblers');
}
  1. In this code, is rif and xup are two arguments.
  2. Is it like passing command line arguments to your script, rather than doing that in the script itself.
  3. What is the main purpose of this module, any real-time examples build in some other languages could be helpful.

It's a quick-and-dirty way to access command line arguments without defining them in your code before actually using them. The second part of the example (which you omitted in your question) actually answers your first question:

$ ./xup.js --rif=55 --xup=9.52
Buy more riffiwobbles

$ ./xup.js --rif 12 --xup 8.1
Sell the xupptumblers

So those arguments end up in argv.rif and argv.xup.