Skip to content
Myr

split.js

This file

Path

examples/split.js

16 lines · 458 bytes · JavaScript

Last changed by

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

History of this file

Take it

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

line 1why, one step back
1const { program } = require('commander');

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

lines 2–4why, one step back
2
3// This is used as an example in the README for the Quick Start.4

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 5why, one step back
5program.option('--first').option('-s, --separator <char>');

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

lines 6–16why, one step back
6
7program.parse();89const options = program.opts();10const limit = options.first ? 1 : undefined;11console.log(program.args[0].split(options.separator, limit));1213// Try the following:14// node split -s / --fits a/b/c15// node split -s / --first a/b/c16// node split --separator=, a,b,c