"use strict"; require("typings-global"); var plugins = require("./smartcli.plugins"); var SmartcliChecks = require("./smartcli.checks"); /** * gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument * @param argumentLevel * @returns {{specified: (boolean|boolean), name}} */ exports.commandArgument = function (argumentLevel) { var commandArgument = { specified: false, name: "undefined", level: argumentLevel }; if (argumentLevel < 1) { plugins.beautylog.error("smartcli.get.argument cannot be invoked with an argumentLevel smaller than 1"); return commandArgument; } if (SmartcliChecks.commandArgumentPresence(argumentLevel)) { commandArgument.specified = true; commandArgument.name = plugins.argv._[argumentLevel]; } return commandArgument; }; /** * returns array with commandArgs * @returns {CliCommandArgument[]} */ exports.commandArgs = function () { var commandArgs = []; var argsArray = exports.commandArray().slice(0); argsArray.shift(); for (var item in argsArray) { var commandArgument_1 = { specified: true, name: argsArray[item], level: parseInt(item) + 1 }; commandArgs.push(commandArgument_1); } return commandArgs; }; /** * returns complete command array * @returns {any} */ exports.commandArray = function () { var commandArray = plugins.argv._; return commandArray; }; /** * returns a cli option * @param optionName * @returns {CliOption} */ exports.option = function (optionName) { var cliOption = { name: optionName, specified: false, value: false }; if (plugins.smartparam.exists(plugins.argv, optionName)) { cliOption.name = optionName; cliOption.specified = true; cliOption.value = plugins.argv[optionName]; //we already know from the "if" above that the value is available. } return cliOption; }; exports.options = function () { var options = {}; for (var key in plugins.argv) { if (key != "_") { options['key'] = plugins.argv['key']; } } return options; }; /** * returns Directory of cwd * @returns {{path: string}} */ exports.cwd = function () { return { path: process.cwd() }; }; //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmdldHRlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUd4QixJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sY0FBYyxXQUFXLG1CQUFtQixDQUFDL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