UNPKG

vamtiger-argv

Version:

This contains convenience methods for accessing commandline arguments.

37 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const raw_arguments_1 = require("../raw-arguments"); const initialize_1 = require("../initialize"); const get_next_argument_1 = require("../get-next-argument"); class Args extends Map { constructor() { super(); this.first = undefined; this.raw.forEach((arg, index, args) => this._initialize(arg, index, args)); } get raw() { return raw_arguments_1.default; } next(arg) { const args = this.raw; return get_next_argument_1.default({ arg, args }); } getAll(arg) { const argRegex = new RegExp(`${arg}$`); const args = this.raw; const values = new Set(); args.forEach((currentArg, index) => { if (currentArg.match(arg)) { values.add(args[++index]); } }); return Array.from(values); } _initialize(arg, index, args) { const context = this; initialize_1.default({ context, arg, index, args }); } } exports.default = Args; ; //# sourceMappingURL=index.js.map