Skip to content
Myr

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 file

Take it

Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c

lines 1–20why, one step back
1#!/usr/bin/env node
23// This example is used as an example in the README for the action handler.45// const { Command } = require('commander'); // (normal include)6const { Command } = require('../'); // include commander in git clone of commander repo7const program = new Command();89program10 .command('serve')11 .argument('<script>')12 .option('-p, --port <number>', 'port number', 80)13 .action(function() {14 console.error('Run script %s on port %s', this.args[0], this.opts().port);15 });1617program.parse();1819// Try the following:20// node action-this.js serve --port 8080 index.js