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 fileTake it
123456789101112131415161718192021#!/usr/bin/env node
// This is used as an example in the README for variadic options.
import { Command } from 'commander';const program = new Command();
program .option('-n, --number <value...>', 'specify numbers') .option('-l, --letter [value...]', 'specify letters');
program.parse();
console.log('Options: ', program.opts());console.log('Remaining arguments: ', program.args);
// Try the following:// node options-variadic.js -n 1 2 3 --letter a b c// node options-variadic.js --letter=A -n80 operand// node options-variadic.js --letter -n 1 -n 2 3 -- operand