2016-06-10 00:27:04 +00:00
|
|
|
import "typings-global";
|
2015-11-08 23:58:40 +00:00
|
|
|
|
2016-05-12 01:27:45 +00:00
|
|
|
import "./smartcli.interfaces";
|
2016-03-14 06:12:00 +00:00
|
|
|
import plugins = require("./smartcli.plugins");
|
2015-11-05 20:43:34 +00:00
|
|
|
|
|
|
|
|
2016-03-14 06:12:00 +00:00
|
|
|
/**
|
|
|
|
* checks for an special command argument at a certain position, returns true if matches, returns false if not
|
|
|
|
* @param level
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export let commandArgument = function(commandArgumentString:string,level:number = 1):boolean {
|
|
|
|
if(commandArgumentPresence(level) && (plugins.argv._[level] == commandArgumentString )) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2015-11-08 23:58:40 +00:00
|
|
|
|
2016-03-14 06:12:00 +00:00
|
|
|
export let commandArgumentPresence = function(level:number = 1) {
|
|
|
|
if(plugins.argv._.length >= (level + 1)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2015-11-05 20:43:34 +00:00
|
|
|
|
2016-03-14 06:12:00 +00:00
|
|
|
/**
|
|
|
|
* checks for a specific option string, returns true if yes, returns false if no
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export let option = function(optionString):boolean {
|
|
|
|
if(plugins.smartparam.exists(plugins.argv, optionString)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2015-11-05 20:43:34 +00:00
|
|
|
|
2016-03-14 06:12:00 +00:00
|
|
|
export let optionPresence = function():boolean {
|
|
|
|
if (plugins.argv.indexOf() != -1) {
|
|
|
|
return true
|
2015-11-05 20:43:34 +00:00
|
|
|
}
|
2016-03-14 06:12:00 +00:00
|
|
|
return false;
|
|
|
|
};
|