@jil/args
Version:
A convention based argument parsing and formatting library, with strict validation checks
19 lines • 648 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCommand = void 0;
/**
* Check that an argument is a command by looping through a list of available
* commands, or running a command checking function. If an exact match,
* or looks like a sub-command ("cmd:sub") return true.
*/
function isCommand(arg, commandCheck) {
if (Array.isArray(commandCheck) && commandCheck.length > 0) {
return commandCheck.includes(arg);
}
if (typeof commandCheck === 'function') {
return commandCheck(arg);
}
return false;
}
exports.isCommand = isCommand;
//# sourceMappingURL=isCommand.js.map