1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function option(defaults = {}) {
|
4 | return (options) => {
|
5 | options = options || {};
|
6 | return Object.assign({ parse: (i) => i }, defaults, options, { input: [], multiple: !!options.multiple, type: 'option', value: options.multiple ? [] : undefined });
|
7 | };
|
8 | }
|
9 | exports.option = option;
|
10 | exports.flags = {
|
11 | boolean: (options = {}) => {
|
12 | return Object.assign({}, options, { allowNo: !!options.allowNo, type: 'boolean', value: false });
|
13 | },
|
14 | integer: option({
|
15 | parse: input => {
|
16 | if (!/^[0-9]+$/.test(input))
|
17 | throw new Error(`Expected an integer but received: ${input}`);
|
18 | return parseInt(input, 10);
|
19 | },
|
20 | }),
|
21 | option,
|
22 | string: option(),
|
23 | };
|
24 | exports.defaultFlags = {
|
25 | color: exports.flags.boolean({ allowNo: true }),
|
26 | };
|