Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Command Line Interfaces In Node.JS

Building Command Line Interfaces In Node.JS

domharrington

May 11, 2012
Tweet

Other Decks in Programming

Transcript

  1. BUILDING COMMAND LINE INTERFACES IN Node.JS 1 Copyright © 2012

    Clock Limited Clock ® is a registered trademark of Clock limited in the EU and other territories Registered in England and Wales No.3457724 VAT Registered No. 706 7654 20
  2. 4

  3. Perfectly fine if you only need one argument E.g. accessing

    the first argument: process.argv[2] Parsing of options becomes unmanageable 5 PROBLEMS WITH THIS APPROACH
  4. Module to help ease the pain of parsing command-line options

    Simple, natural API Auto generated --help and --version 6 COMMANDER.JS https://github.com/visionmedia/commander.js/
  5. 7

  6. 8

  7. Options don't need to be defined All options are parsed

    automatically Also has default values, aliases Many more features 9 NODE-OPTIMIST https://github.com/substack/node-optimist
  8. 10

  9. 11