Skip to content
Myr

options-variadic.js

This file

Path

examples/options-variadic.js

20 lines · 600 bytes · JavaScript

Last changed by

Use standard import in examples (#2168)John Geebefore adoption41b12cf

History of this file

Take it

The walk stopped after 200 commits: lines older than 3103c6b point at it.

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 1–4why, one step back
1#!/usr/bin/env node
23// This is used as an example in the README for variadic options.4

Use standard import in examples (#2168)John Geebefore adoption41b12cf

line 5why, one step back
5const commander = require('commander');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

lines 6–20why, one step back
6const program = new commander.Command();
78program9 .option('-n, --number <value...>', 'specify numbers')10 .option('-l, --letter [value...]', 'specify letters');1112program.parse();1314console.log('Options: ', program.opts());15console.log('Remaining arguments: ', program.args);1617// Try the following:18// node options-variadic.js -n 1 2 3 --letter a b c19// node options-variadic.js --letter=A -n80 operand20// node options-variadic.js --letter -n 1 -n 2 3 -- operand