Skip to content
Myr

options-variadic.js

This file

Path

examples/options-variadic.js

20 lines · 587 bytes · JavaScript

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at it.

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

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

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

lines 5–6why, one step back
5import { Command } from 'commander';
6const program = new Command();

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 7–20why, one step back
7
8program9 .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