/
Holixus
/
node-getopt
Обзор
Документация
Войти
/
Holixus
/
node-getopt
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/simple.js
22 строки
568 B
Miao Jiang
Catch parse exception.
04 ноя 2012, 16:46
04 ноя 2012, 16:46
2c90842
Код
Авторство
О чём код?
// examples/simple.js // argv parse Getopt = require('..'); // Getopt arguments options // '=': has argument // '[=]': has argument but optional // '+': multiple option supported getopt = new Getopt([ ['s'], ['S' , '='], ['' , 'long-with-arg=ARG'], ['m' , '=+'], ['' , 'color[=COLOR]'], ['h' , 'help'] ]).bindHelp(); // process.argv needs slice(2) for it starts with 'node' and 'script name' // parseSystem is alias of parse(process.argv.slice(2)) // opt = getopt.parseSystem(); opt = getopt.parse(process.argv.slice(2)); console.info(opt);