How does node.js perfectly receive the value passed by the parameter from the command line

  node.js, question

For example, in many php py files! Will accept the value of the parameter from the command line and bring it into the program!
I also want to use node.js to write this way. I feel too laborious to write this way now!

var options = process.argv;
 for(var i=0;  i<canshu.length;  Icaga)
 bracket
 if(options[i].indexOf("-string")==0)
 bracket
 .  .  .  .  .
 bracket
 else if(options[i].indexOf("--start")==0)
 bracket
 ........
 bracket
 bracket

Feeling so good and laborious, is there any better way?

Look at commander.js of the great god tj.

https://github.com/visionmedia/commander.js

Code sample

#!  /usr/bin/env node
 
 /**
 * Module dependencies.
 */
 
 var program = require('commander');
 
 program
 .version('0.0.1')
 .option('-p, --peppers', 'Add peppers')
 .option('-P, --pineapple', 'Add pineapple')
 .option('-b, --bbq', 'Add bbq sauce')
 .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
 .parse(process.argv);
 
 console.log('you ordered a pizza with:');
 if (program.peppers) console.log('  - peppers');
 if (program.pineapple) console.log('  - pineapple');
 if (program.bbq) console.log('  - bbq');
 Log ('-percent s cheese', program.cheese);