mini-commander

a single-file helper for making simple cli tools in nodejs
git clone https://github.com/TanguyAndreani/mini-commander
Log | Files | Refs | README

example.js (674B)


      1 const Commander = require('./mini-commander')
      2 
      3 program = Object.create(Commander)
      4 program.name = 'mini-commander\'s example'
      5 program.description = 'a do-nothing tool'
      6 
      7 program
      8     .command('help')
      9     .alias('h')
     10     .description('display this help message')
     11     .action(() => {
     12         program.usage()
     13         process.exit(0)
     14     })
     15 
     16 program
     17     .command('install')
     18     .alias('i')
     19     .description('install things')
     20     .action(() => {
     21         console.log("installing things!")
     22     })
     23 
     24 program
     25     .command('uninstall')
     26     .alias('u')
     27     .description('uninstall things')
     28     .action(() => {
     29         console.log("uninstalling things!")
     30     })
     31 
     32 program.parse(process.argv)