remove bulk and add some features to Smartcli class

This commit is contained in:
Philipp Kunz 2016-06-10 03:48:01 +02:00
parent 9e76f2afb1
commit e1c2de8a40
14 changed files with 80 additions and 382 deletions

View File

@ -1,15 +0,0 @@
import "typings-global";
import "./smartcli.interfaces";
/**
* checks for an special command argument at a certain position, returns true if matches, returns false if not
* @param level
* @returns {boolean}
*/
export declare let commandArgument: (commandArgumentString: string, level?: number) => boolean;
export declare let commandArgumentPresence: (level?: number) => boolean;
/**
* checks for a specific option string, returns true if yes, returns false if no
* @returns {boolean}
*/
export declare let option: (optionString: any) => boolean;
export declare let optionPresence: () => boolean;

View File

@ -1,41 +0,0 @@
"use strict";
require("typings-global");
require("./smartcli.interfaces");
var plugins = require("./smartcli.plugins");
/**
* checks for an special command argument at a certain position, returns true if matches, returns false if not
* @param level
* @returns {boolean}
*/
exports.commandArgument = function (commandArgumentString, level) {
if (level === void 0) { level = 1; }
if (exports.commandArgumentPresence(level) && (plugins.argv._[level] == commandArgumentString)) {
return true;
}
return false;
};
exports.commandArgumentPresence = function (level) {
if (level === void 0) { level = 1; }
if (plugins.argv._.length >= (level + 1)) {
return true;
}
return false;
};
/**
* checks for a specific option string, returns true if yes, returns false if no
* @returns {boolean}
*/
exports.option = function (optionString) {
if (plugins.smartparam.exists(plugins.argv, optionString)) {
return true;
}
return false;
};
exports.optionPresence = function () {
if (plugins.argv.indexOf() != -1) {
return true;
}
return false;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNoZWNrcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBRXhCLFFBQU8sdUJBQXVCLENBQUMsQ0FBQTtBQUMvQixJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBRy9DOzs7O0dBSUc7QUFDUSx1QkFBZSxHQUFHLFVBQVMscUJB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2U7XG59O1xuXG4vKipcbiAqIGNoZWNrcyBmb3IgYSBzcGVjaWZpYyBvcHRpb24gc3RyaW5nLCByZXR1cm5zIHRydWUgaWYgeWVzLCByZXR1cm5zIGZhbHNlIGlmIG5vXG4gKiBAcmV0dXJucyB7Ym9vbGVhbn1cbiAqL1xuZXhwb3J0IGxldCBvcHRpb24gPSBmdW5jdGlvbihvcHRpb25TdHJpbmcpOmJvb2xlYW4ge1xuICAgIGlmKHBsdWdpbnMuc21hcnRwYXJhbS5leGlzdHMocGx1Z2lucy5hcmd2LCBvcHRpb25TdHJpbmcpKSB7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICByZXR1cm4gZmFsc2U7XG59O1xuXG5leHBvcnQgbGV0IG9wdGlvblByZXNlbmNlID0gZnVuY3Rpb24oKTpib29sZWFuIHtcbiAgICBpZiAocGx1Z2lucy5hcmd2LmluZGV4T2YoKSAhPSAtMSkge1xuICAgICAgICByZXR1cm4gdHJ1ZVxuICAgIH1cbiAgICByZXR1cm4gZmFsc2U7XG59OyJdfQ==

View File

@ -1,10 +1,13 @@
import "typings-global";
import * as interfaces from "./smartcli.interfaces";
export declare class Smartcli {
argv: any;
questionsDone: any;
commands: interfaces.CliCommand[];
parseStarted: any;
commands: any;
questions: any;
version: string;
constructor();
addAlias(keyArg: any, aliasArg: any): void;
addCommand(definitionArg: {
commandName: string;
}): any;
@ -13,5 +16,6 @@ export declare class Smartcli {
questionType: string;
}): void;
addVersion(versionArg: string): void;
standardTask(): any;
startParse(): void;
}

View File

@ -3,16 +3,26 @@ require("typings-global");
var plugins = require("./smartcli.plugins");
var Smartcli = (function () {
function Smartcli() {
this.argv = plugins.argv;
this.questionsDone = plugins.q.defer();
this.parseStarted = plugins.q.defer();
}
Smartcli.prototype.addAlias = function (keyArg, aliasArg) {
this.argv = this.argv.alias(keyArg, aliasArg);
};
;
Smartcli.prototype.addCommand = function (definitionArg) {
var _this = this;
var done = plugins.q.defer();
if (plugins.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
}
else {
return done.reject();
}
this.parseStarted
.then(function () {
if (_this.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
}
else {
return done.reject();
}
});
return done.promsise;
};
;
@ -20,11 +30,31 @@ var Smartcli = (function () {
};
;
Smartcli.prototype.addVersion = function (versionArg) {
this.version = versionArg;
this.parseStarted
.then(function () {
});
};
Smartcli.prototype.standardTask = function () {
var _this = this;
var done = plugins.q.defer();
this.parseStarted
.then(function () {
if (plugins.argv._.length == 0 || _this.commands.length == 0) {
done.resolve();
}
else {
done.reject();
}
;
});
return done.promise;
};
Smartcli.prototype.startParse = function () {
this.parseStarted.resolve();
};
return Smartcli;
}());
exports.Smartcli = Smartcli;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUd4QixJQUFZLE9BQU8sV0FBTSxvQkFDekIsQ0FBQyxDQUQ0QztBQUs3QztJQUlJO1FBQ0ksSUFBSSxDQUFDLGFBQWEsR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzNDLENBQUM7SUFDRCw2QkFBVSxHQUFWLFVBQVcsYUFBa0M7UUFDekMsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDekQsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25CLENBQUM7UUFBQyxJQUFJLEN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pe1xuICAgICAgICB0aGlzLnZlcnNpb24gPSB2ZXJzaW9uQXJnO1xuICAgICAgICB0aGlzLnBhcnNlU3RhcnRlZFxuICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuXG4gICAgICAgICAgICB9KVxuICAgIH1cbiAgICBzdGFuZGFyZFRhc2soKXtcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcbiAgICAgICAgdGhpcy5wYXJzZVN0YXJ0ZWRcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICBpZihwbHVnaW5zLmFyZ3YuXy5sZW5ndGggPT0gMCB8fCB0aGlzLmNvbW1hbmRzLmxlbmd0aCA9PSAwKXtcbiAgICAgICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZG9uZS5yZWplY3QoKTtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIHN0YXJ0UGFyc2UoKXtcbiAgICAgICAgdGhpcy5wYXJzZVN0YXJ0ZWQucmVzb2x2ZSgpO1xuICAgIH1cblxufSJdfQ==

View File

@ -1,30 +0,0 @@
import "typings-global";
import * as interfaces from "./smartcli.interfaces";
/**
* gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument
* @param argumentLevel
* @returns {{specified: (boolean|boolean), name}}
*/
export declare let commandArgument: (argumentLevel: any) => interfaces.CliCommandArgument;
/**
* returns array with commandArgs
* @returns {CliCommandArgument[]}
*/
export declare let commandArgs: () => interfaces.CliCommandArgument[];
/**
* returns complete command array
* @returns {any}
*/
export declare let commandArray: () => string[];
/**
* returns a cli option
* @param optionName
* @returns {CliOption}
*/
export declare let option: (optionName: string) => interfaces.CliOption;
export declare let options: () => {};
/**
* returns Directory of cwd
* @returns {{path: string}}
*/
export declare let cwd: () => interfaces.Directory;

File diff suppressed because one or more lines are too long

View File

@ -1,19 +0,0 @@
import "typings-global";
export interface CliCommand {
specified: boolean;
name: string;
arguments: CliCommandArgument[];
}
export interface CliOption {
name: string;
specified: boolean;
value: any;
}
export interface Directory {
path: string;
}
export interface CliCommandArgument {
specified: boolean;
name: string;
level: number;
}

View File

@ -1,4 +0,0 @@
"use strict";
require("typings-global");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQSIsImZpbGUiOiJzbWFydGNsaS5pbnRlcmZhY2VzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcblxuZXhwb3J0IGludGVyZmFjZSBDbGlDb21tYW5kIHtcbiAgICBzcGVjaWZpZWQ6IGJvb2xlYW47XG4gICAgbmFtZTogc3RyaW5nO1xuICAgIGFyZ3VtZW50czpDbGlDb21tYW5kQXJndW1lbnRbXTtcbn1cblxuZXhwb3J0IGludGVyZmFjZSBDbGlPcHRpb24ge1xuICAgIG5hbWU6IHN0cmluZztcbiAgICBzcGVjaWZpZWQ6Ym9vbGVhbjtcbiAgICB2YWx1ZTogYW55O1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIERpcmVjdG9yeSB7XG4gICAgcGF0aDogc3RyaW5nO1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIENsaUNvbW1hbmRBcmd1bWVudCB7XG4gICAgc3BlY2lmaWVkOmJvb2xlYW47XG4gICAgbmFtZTpzdHJpbmc7XG4gICAgbGV2ZWw6bnVtYmVyO1xufSJdfQ==

View File

@ -1,6 +1,6 @@
"use strict";
require("typings-global");
exports.argv = require('yargs').argv;
exports.argv = require('yargs');
exports.beautylog = require("beautylog");
exports.cliff = require("cliff");
exports.inquirer = require("inquirer");
@ -8,4 +8,4 @@ exports.path = require("path");
exports.q = require("q");
exports.smartparam = require("smartparam");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUViLFlBQUksR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUMsSUFBSSxDQUFDO0FBQzdCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGFBQUssR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDekIsZ0JBQVEsR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDL0IsWUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGtCQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0Y2xpLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xuXG5leHBvcnQgbGV0IGFyZ3YgPSByZXF1aXJlKCd5YXJncycpLmFyZ3Y7XG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XG5leHBvcnQgbGV0IGNsaWZmID0gcmVxdWlyZShcImNsaWZmXCIpO1xuZXhwb3J0IGxldCBpbnF1aXJlciA9IHJlcXVpcmUoXCJpbnF1aXJlclwiKTtcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBxID0gcmV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vcnQgbGV0IHNtYXJ0cGFyYW0gPSByZXF1aXJlKFwic21hcnRwYXJhbVwiKTsiXX0=

View File

@ -1,42 +0,0 @@
import "typings-global";
import "./smartcli.interfaces";
import plugins = require("./smartcli.plugins");
/**
* 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;
};
export let commandArgumentPresence = function(level:number = 1) {
if(plugins.argv._.length >= (level + 1)) {
return true;
}
return false;
};
/**
* 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;
};
export let optionPresence = function():boolean {
if (plugins.argv.indexOf() != -1) {
return true
}
return false;
};

View File

@ -1,35 +1,59 @@
import "typings-global";
import * as interfaces from "./smartcli.interfaces"
import * as plugins from "./smartcli.plugins"
import * as SmartcliChecks from "./smartcli.checks";
import * as SmartcliGetters from "./smartcli.getters";
import * as SmartcliInteractions from "./smartcli.interaction";
export class Smartcli {
argv;
questionsDone;
commands:interfaces.CliCommand[];
parseStarted;
commands;
questions;
version:string;
constructor(){
this.argv = plugins.argv;
this.questionsDone = plugins.q.defer();
this.parseStarted = plugins.q.defer();
}
addAlias(keyArg,aliasArg){
this.argv = this.argv.alias(keyArg,aliasArg);
};
addCommand(definitionArg:{commandName:string}){
let done = plugins.q.defer();
if (plugins.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
} else {
return done.reject();
}
this.parseStarted
.then(() => {
if (this.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
} else {
return done.reject();
}
});
return done.promsise;
};
addQuestion(definitionArg:{questionString:string,questionType:string}){
};
addVersion(versionArg:string){
this.version = versionArg;
this.parseStarted
.then(() => {
})
}
standardTask(){
let done = plugins.q.defer();
this.parseStarted
.then(() => {
if(plugins.argv._.length == 0 || this.commands.length == 0){
done.resolve();
} else {
done.reject();
};
});
return done.promise;
}
startParse(){
this.parseStarted.resolve();
}
}

View File

@ -1,97 +0,0 @@
import "typings-global";
import * as interfaces from "./smartcli.interfaces";
import plugins = require("./smartcli.plugins");
import 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}}
*/
export let commandArgument = function(argumentLevel):interfaces.CliCommandArgument {
var commandArgument:interfaces.CliCommandArgument = {
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[]}
*/
export let commandArgs = function():interfaces.CliCommandArgument[] {
var commandArgs:interfaces.CliCommandArgument[] = [];
var argsArray = commandArray().slice(0);
argsArray.shift();
for (let item in argsArray){
let commandArgument:interfaces.CliCommandArgument = {
specified:true,
name:argsArray[item],
level: parseInt(item) + 1
}
commandArgs.push(commandArgument);
}
return commandArgs;
};
/**
* returns complete command array
* @returns {any}
*/
export let commandArray = function ():string[] {
var commandArray = plugins.argv._;
return commandArray;
};
/**
* returns a cli option
* @param optionName
* @returns {CliOption}
*/
export let option = function(optionName:string):interfaces.CliOption {
var cliOption:interfaces.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;
};
export let 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}}
*/
export let cwd = function():interfaces.Directory {
return {
path: process.cwd()
}
};

View File

@ -1,23 +0,0 @@
import "typings-global";
export interface CliCommand {
specified: boolean;
name: string;
arguments:CliCommandArgument[];
}
export interface CliOption {
name: string;
specified:boolean;
value: any;
}
export interface Directory {
path: string;
}
export interface CliCommandArgument {
specified:boolean;
name:string;
level:number;
}

View File

@ -1,6 +1,6 @@
import "typings-global";
export let argv = require('yargs').argv;
export let argv = require('yargs');
export let beautylog = require("beautylog");
export let cliff = require("cliff");
export let inquirer = require("inquirer");