Gen.js
#!/usr/bin/env nodevarprogram = require (' Commander '); Program. Version (' 0.0.1 '). Option ('-C,--chdir <path> ', ' Change the working directory '). Option ('-C,--config <path> ', ' set config path. defaults to./deploy.conf '). Option ('-T,--no-tests ', ' Ignore Test hook '). Option ('-P,--peppers ', ' Add peppers '). Option ('-P,--pineapple ', ' Add pineapple '). Option ('-B,--bbq-sauce ', ' Add BBQ sauce '). Option ('--p,--fuck-you ', ' fuckyou '). Option (' Build--env <fuckyou> ', ' FUCKYOU2 '). Parse (PROCESS.ARGV);if(program.peppers) Console.log ('-peppers '));if(program.pineapple) Console.log ('-pineapple '));if(program.bbqsauce) Console.log ('-BBQ '));if(program.fuckyou) Console.log (' fuckyou '));if(program.env && Program.args.length! = 0{console.log (Program.args);} program. Command (' Init '). Description (' Run Remote setup commands '). Action (function() {Console.log (' Setup '); }); Program. Command (' EXEC <cmd> '). Description (' Run the given remote command '). Action (function(cmd) {console.log (' Exec '%s ', CMD); }); Program. Command (' Teardown <dir> [otherdirs ...] '). Description (' Run teardown commands '). Action (function(dir, otherdirs) {Console.log (' dir '%s ', dir); if(otherdirs) {Otherdirs.foreach (function(ODir) {Console.log (' dir '%s ', ODir); }); } });
Nodejs Commander Command-line artifact Simple example