action-this.js
This file
Path
examples/action-this.js
20 lines · 589 bytes · JavaScript
Last changed by
Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
History of this fileTake it
123456789101112131415161718192021#!/usr/bin/env node
// This example is used as an example in the README for the action handler.
// const { Command } = require('commander'); // (normal include)const { Command } = require('../'); // include commander in git clone of commander repoconst program = new Command();
program .command('serve') .argument('<script>') .option('-p, --port <number>', 'port number', 80) .action(function() { console.error('Run script %s on port %s', this.args[0], this.opts().port); });
program.parse();
// Try the following:// node action-this.js serve --port 8080 index.js