Function Range (val) { Return Val.split (' ... '). Map (number); }
Function List (val) { Return Val.split (', '); }
function Collect (val, Memo) { Memo.push (Val); return memo; }
function Increaseverbosity (V, total) { return total + 1; }
Program . Version (' 0.0.1 ') . Usage (' [options] <file ...> ') . option ('-I,--integer <n> ', ' an integer argument ', parseint) . Option (' F,--float <n> ', ' A float argument ', parsefloat) . Option (' R,--range <a> <b> ', ' A range ', range . Option ('-L,--list <items> ', ' A list ', list) . Option (' O,--optional [value] ', ' an optional value ') . option ('-C,--collect [value] ', ' A repeatable value ', collect, []) . Option ('-V,--verbose ', ' A value ' can be increased ', increaseverbosity, 0) . Parse (PROCESS.ARGV); Console.log (' int:%j ', Program.integer); Console.log (' float:%j ', program.float); Console.log (' Optional:%j ', program.optional); Program.range = Program.range | | []; Console.log (' Range:%j. %j ', program.range[0], program.range[1]); Console.log (' list:%j ', program.list); Console.log (' Collect:%j ', program.collect); Console.log (' verbosity:%j ', program.verbose); Console.log (' args:%j ', Program.args); |