split.js
This file
Path
examples/split.js
18 lines · 464 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake it
12345678910111213141516171819const { program } = require('commander');
// This is used as an example in the README for the Quick Start.
program .option('--first') .option('-s, --separator <char>');
program.parse();
const options = program.opts();const limit = options.first ? 1 : undefined;console.log(program.args[0].split(options.separator, limit));
// Try the following:// node split -s / --fits a/b/c// node split -s / --first a/b/c// node split --separator=, a,b,c