Skip to content
Myr

split.js

This file

Path

examples/split.js

19 lines · 575 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–19why, one step back
1// const { program } = require('commander'); // (normal include)
2const { program } = require('../'); // include commander in git clone of commander repo34// This is used as an example in the README for the Quick Start.56program7 .option('--first')8 .option('-s, --separator <char>');910program.parse();1112const options = program.opts();13const limit = options.first ? 1 : undefined;14console.log(program.args[0].split(options.separator, limit));1516// Try the following:17// node split -s / --fits a/b/c18// node split -s / --first a/b/c19// node split --separator=, a,b,c