Start restructuring to use a smarter Smartcli class that handles command evaluation for you

This commit is contained in:
Philipp Kunz 2016-06-10 03:10:21 +02:00
parent cf78839e12
commit 9e76f2afb1
27 changed files with 124 additions and 525 deletions

12
dist/index.d.ts vendored
View File

@ -1,10 +1,2 @@
import * as SmartcliChecks from "./smartcli.checks"; import "typings-global";
import * as SmartcliGetters from "./smartcli.getters"; export { Smartcli } from "./smartcli.classes.smartcli";
import * as SmartcliInteractions from "./smartcli.interaction";
export declare let commander: any;
export declare let inquirer: any;
export declare let cliff: any;
export declare let argv: any;
export declare let check: typeof SmartcliChecks;
export declare let get: typeof SmartcliGetters;
export declare let interaction: typeof SmartcliInteractions;

29
dist/index.js vendored
View File

@ -1,27 +1,6 @@
/// <reference path="typings/index.d.ts" />
"use strict"; "use strict";
var plugins = require("./smartcli.plugins"); require("typings-global");
var SmartcliChecks = require("./smartcli.checks"); var smartcli_classes_smartcli_1 = require("./smartcli.classes.smartcli");
var SmartcliGetters = require("./smartcli.getters"); exports.Smartcli = smartcli_classes_smartcli_1.Smartcli;
var SmartcliInteractions = require("./smartcli.interaction");
/* ------------------------------------------------ *
* ---------- plugins for direct use -------------- *
* ------------------------------------------------ */
exports.commander = plugins.commander; //commander allows cool chaining of cli actions
exports.inquirer = plugins.inquirer; //inquirer is for asking questions
exports.cliff = plugins.cliff; // formats cli output
exports.argv = plugins.argv; //argv gets initial cli commands and options.
/* ------------------------------------------------ *
* ---------- checks ------------------------------ *
* ------------------------------------------------ */
exports.check = SmartcliChecks;
/* ------------------------------------------------ *
* ---------- getters ----------------------------- *
* ------------------------------------------------ */
exports.get = SmartcliGetters;
/* ------------------------------------------------ *
* ---------- interaction ----------------------------- *
* ------------------------------------------------ */
exports.interaction = SmartcliInteractions;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDJDQUEyQzs7QUFHM0M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import "./smartcli.interfaces"; import "./smartcli.interfaces";
/**
* checks for a special command string and returns true if found.
* @param commandString
* @returns {boolean}
*/
export declare let command: (commandString: string) => boolean;
/**
* checks if a command is present, returns true if yes, false if no.
* @returns {boolean}
*/
export declare let commandPresence: () => boolean;
/** /**
* checks for an special command argument at a certain position, returns true if matches, returns false if not * checks for an special command argument at a certain position, returns true if matches, returns false if not
* @param level * @param level

View File

@ -1,28 +1,7 @@
/// <reference path="typings/index.d.ts" />
"use strict"; "use strict";
require("typings-global");
require("./smartcli.interfaces"); require("./smartcli.interfaces");
var plugins = require("./smartcli.plugins"); var plugins = require("./smartcli.plugins");
/**
* checks for a special command string and returns true if found.
* @param commandString
* @returns {boolean}
*/
exports.command = function (commandString) {
if (plugins.argv._.indexOf(commandString) == 0) {
return true;
}
return false;
};
/**
* checks if a command is present, returns true if yes, false if no.
* @returns {boolean}
*/
exports.commandPresence = function () {
if (plugins.argv._.length > 0) {
return true;
}
return false;
};
/** /**
* checks for an special command argument at a certain position, returns true if matches, returns false if not * checks for an special command argument at a certain position, returns true if matches, returns false if not
* @param level * @param level
@ -59,4 +38,4 @@ exports.optionPresence = function () {
return false; return false;
}; };
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNoZWNrcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7O0FBRTNDLFFBQU8sdUJBQXVCLENBQUMsQ0FBQTtBQUMvQixJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBRS9DOzs7O0dBSUc7QUFDUSxlQUFPLEdBQUcsVUFBUyxhQUFvQjtJQUM5QyxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM3QyxNQUFNLEN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gIH1cbiAgICByZXR1cm4gZmFsc2U7XG59O1xuXG4vKipcbiAqIGNoZWNrcyBmb3IgYSBzcGVjaWZpYyBvcHRpb24gc3RyaW5nLCByZXR1cm5zIHRydWUgaWYgeWVzLCByZXR1cm5zIGZhbHNlIGlmIG5vXG4gKiBAcmV0dXJucyB7Ym9vbGVhbn1cbiAqL1xuZXhwb3J0IGxldCBvcHRpb24gPSBmdW5jdGlvbihvcHRpb25TdHJpbmcpOmJvb2xlYW4ge1xuICAgIGlmKHBsdWdpbnMuc21hcnRwYXJhbS5leGlzdHMocGx1Z2lucy5hcmd2LCBvcHRpb25TdHJpbmcpKSB7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICByZXR1cm4gZmFsc2U7XG59O1xuXG5leHBvcnQgbGV0IG9wdGlvblByZXNlbmNlID0gZnVuY3Rpb24oKTpib29sZWFuIHtcbiAgICBpZiAocGx1Z2lucy5hcmd2LmluZGV4T2YoKSAhPSAtMSkge1xuICAgICAgICByZXR1cm4gdHJ1ZVxuICAgIH1cbiAgICByZXR1cm4gZmFsc2U7XG59OyJdfQ==

View File

@ -1,3 +0,0 @@
export declare class smartcli {
constructor();
}

View File

@ -1,9 +0,0 @@
"use strict";
var smartcli = (function () {
function smartcli() {
}
return smartcli;
}());
exports.smartcli = smartcli;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0lBRUk7SUFFQSxDQUFDO0lBQ0wsZUFBQztBQUFELENBTEEsQUFLQyxJQUFBO0FBTFksZ0JBQVEsV0FLcEIsQ0FBQSIsImZpbGUiOiJzbWFydGNsaS5jbGFzc2VzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIHNtYXJ0Y2xpIHtcclxuICAgIFxyXG4gICAgY29uc3RydWN0b3IoKXtcclxuICAgICAgICBcclxuICAgIH1cclxufSJdfQ==

View File

@ -1,2 +1,17 @@
export declare class smartcli { import "typings-global";
import * as interfaces from "./smartcli.interfaces";
export declare class Smartcli {
questionsDone: any;
commands: interfaces.CliCommand[];
questions: any;
constructor();
addCommand(definitionArg: {
commandName: string;
}): any;
addQuestion(definitionArg: {
questionString: string;
questionType: string;
}): void;
addVersion(versionArg: string): void;
startParse(): void;
} }

View File

@ -1,9 +1,30 @@
"use strict"; "use strict";
var smartcli = (function () { require("typings-global");
function smartcli() { var plugins = require("./smartcli.plugins");
var Smartcli = (function () {
function Smartcli() {
this.questionsDone = plugins.q.defer();
} }
return smartcli; Smartcli.prototype.addCommand = function (definitionArg) {
var done = plugins.q.defer();
if (plugins.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
}
else {
return done.reject();
}
return done.promsise;
};
;
Smartcli.prototype.addQuestion = function (definitionArg) {
};
;
Smartcli.prototype.addVersion = function (versionArg) {
};
Smartcli.prototype.startParse = function () {
};
return Smartcli;
}()); }());
exports.smartcli = smartcli; exports.Smartcli = Smartcli;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0lBQUE7SUFFQSxDQUFDO0lBQUQsZUFBQztBQUFELENBRkEsQUFFQyxJQUFBO0FBRlksZ0JBQVEsV0FFcEIsQ0FBQSIsImZpbGUiOiJzbWFydGNsaS5jbGFzc2VzLnNtYXJ0Y2xpLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIHNtYXJ0Y2xpIHtcclxuICAgIFxyXG59Il19 //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXM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30pe1xuICAgICAgICBcbiAgICB9O1xuICAgIGFkZFZlcnNpb24odmVyc2lvbkFyZzpzdHJpbmcpe1xuXG4gICAgfVxuICAgIHN0YXJ0UGFyc2UoKXtcblxuICAgIH1cblxufSJdfQ==

View File

@ -1,10 +1,5 @@
import "typings-global";
import * as interfaces from "./smartcli.interfaces"; import * as interfaces from "./smartcli.interfaces";
/**
*
* @param commandString
* @returns {{specified: boolean, name: any, arguments: CliCommandArgument}}
*/
export declare let command: () => interfaces.CliCommand;
/** /**
* gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument * gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument
* @param argumentLevel * @param argumentLevel

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
import "typings-global";
import "./smartcli.interfaces"; import "./smartcli.interfaces";
/** /**
* executes callback with answer to question as argument * executes callback with answer to question as argument

View File

@ -1,5 +1,5 @@
/// <reference path="typings/index.d.ts" />
"use strict"; "use strict";
require("typings-global");
require("./smartcli.interfaces"); require("./smartcli.interfaces");
var plugins = require("./smartcli.plugins"); var plugins = require("./smartcli.plugins");
/** /**
@ -52,4 +52,4 @@ exports.getChoice = function (questionString, choiceOptions, cb) {
}); });
}; };
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmludGVyYWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDJDQUEyQzs7QUFFM0MsUUFBTyx1QkFBdUIsQ0FBQyxDQUFBO0FBQy9CLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFL0M7Ozs7O0dBS0c7QUFDUSxpQkFBUyxHQUFHLFVBQVMsY0FBcUIsRUFBRSxFQUFFO0lBQ3JELEVBQUUsQ0FBQyxDQUFDLE9BQU8sY0FBYyxJQUFJLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDcEMsT0FBTyxDQUFDLF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AgIH0pO1xuXG59OyJdfQ==

View File

@ -1,3 +1,9 @@
import "typings-global";
export interface CliCommand {
specified: boolean;
name: string;
arguments: CliCommandArgument[];
}
export interface CliOption { export interface CliOption {
name: string; name: string;
specified: boolean; specified: boolean;
@ -6,11 +12,6 @@ export interface CliOption {
export interface Directory { export interface Directory {
path: string; path: string;
} }
export interface CliCommand {
specified: boolean;
name: string;
arguments: CliCommandArgument[];
}
export interface CliCommandArgument { export interface CliCommandArgument {
specified: boolean; specified: boolean;
name: string; name: string;

View File

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

View File

@ -1,7 +1,8 @@
export declare let path: any; import "typings-global";
export declare let argv: any;
export declare let beautylog: any; export declare let beautylog: any;
export declare let cliff: any; export declare let cliff: any;
export declare let commander: any;
export declare let inquirer: any; export declare let inquirer: any;
export declare let path: any;
export declare let q: any;
export declare let smartparam: any; export declare let smartparam: any;
export declare let argv: any;

View File

@ -1,11 +1,11 @@
/// <reference path="typings/index.d.ts" />
"use strict"; "use strict";
exports.path = require("path"); require("typings-global");
exports.argv = require('yargs').argv;
exports.beautylog = require("beautylog"); exports.beautylog = require("beautylog");
exports.cliff = require("cliff"); exports.cliff = require("cliff");
exports.commander = require("commander");
exports.inquirer = require("inquirer"); exports.inquirer = require("inquirer");
exports.path = require("path");
exports.q = require("q");
exports.smartparam = require("smartparam"); exports.smartparam = require("smartparam");
exports.argv = require('yargs').argv;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsMkNBQTJDOztBQUVoQyxZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGFBQUssR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDekIsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsZ0JBQVEsR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDL0Isa0JBQVUs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BQUM7QUFDL0IsWUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGtCQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0Y2xpLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xuXG5leHBvcnQgbGV0IGFyZ3YgPSByZXF1aXJlKCd5YXJncycpLmFyZ3Y7XG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XG5leHBvcnQgbGV0IGNsaWZmID0gcmVxdWlyZShcImNsaWZmXCIpO1xuZXhwb3J0IGxldCBpbnF1aXJlciA9IHJlcXVpcmUoXCJpbnF1aXJlclwiKTtcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBxID0gcmVxdWlyZShcInFcIik7XG5leHBvcnQgbGV0IHNtYXJ0cGFyYW0gPSByZXF1aXJlKFwic21hcnRwYXJhbVwiKTsiXX0=

View File

@ -30,8 +30,8 @@
"dependencies": { "dependencies": {
"beautylog": "^5.0.8", "beautylog": "^5.0.8",
"cliff": "^0.1.10", "cliff": "^0.1.10",
"commander": "^2.9.0",
"inquirer": "^1.0.3", "inquirer": "^1.0.3",
"q": "^1.4.1",
"smartparam": "0.0.7", "smartparam": "0.0.7",
"typings-global": "^1.0.3", "typings-global": "^1.0.3",
"yargs": "^4.7.1" "yargs": "^4.7.1"

15
test/test.d.ts vendored
View File

@ -1,14 +1 @@
/// <reference path="../ts/typings/index.d.ts" /> import "typings-test";
declare let smartcli: any;
declare let beautylog: any;
declare let should: any;
declare var checkCommandArgumentTest: () => void;
declare var checkCommandArgumentPresenceTest: () => void;
declare var getCommandTest: () => void;
declare var getCommandArgumentTest: () => void;
declare var getCommandArgsTest: () => void;
declare var getOptionTest: () => void;
declare var getCwdTest: () => void;
declare var interactionGetAnswerTest: () => void;
declare var interactionGetChoiceTest: () => void;
declare var endTests: () => void;

File diff suppressed because one or more lines are too long

View File

@ -4,163 +4,4 @@ let smartcli = require("../dist/index.js");
let beautylog = require("beautylog"); let beautylog = require("beautylog");
let should = require("should"); let should = require("should");
/* ------------------------------------------------------------------ *
* ------------------- CHECKS TESTS --------------------------------- *
* ------------------------------------------------------------------ */
describe("smartcli",function(){
describe(".check",function(){
describe(".command",function(){
it("should return true when specified command is found",function(){
smartcli.check.command("jazz").should.be.true();
});
it("should return false when specified command is NOT found",function(){
smartcli.check.command("rock").should.be.false();
});
});
describe(".commandPresence",function(){
});
});
});
var checkCommandArgumentTest = function() {
if (smartcli.check.commandArgument("jam",1)) {
beautylog.success('There is a level 1 argument! Perfect!');
} else {
beautylog.error('There seems to be no level 1 argument... This is wrong');
process.exit(1);
}
if (!smartcli.check.commandArgument("session",2)) {
beautylog.success('There is no level 2 argument with the name of "session"! Perfect!');
} else {
beautylog.error('There seems to be a level 2 argument with the name of "session"! This is wrong');
process.exit(1);
}
};
checkCommandArgumentTest();
var checkCommandArgumentPresenceTest = function() {
if (smartcli.check.commandArgumentPresence(1)) {
beautylog.success('There is a level 1 argument! Perfect!');
} else {
beautylog.error('There seems to be no level 1 argument... This is wrong');
process.exit(1);
}
if (!smartcli.check.commandArgumentPresence(2)) {
beautylog.success('There is no level 2 argument! Perfect!');
} else {
beautylog.error('There seems to be a level 2 argument... This is wrong');
process.exit(1);
}
};
checkCommandArgumentPresenceTest();
/* ------------------------------------------------------------------ *
* ------------------- GETTERS TESTS -------------------------------- *
* ------------------------------------------------------------------ */
var getCommandTest = function(){
var cliCommand = smartcli.get.command();
if(cliCommand.name == "jazz") {
beautylog.success('The specified command name is "jazz". Perfect!');
} else {
beautylog.error('The specified command name is not "jazz". Something is wrong!');
process.exit(1);
}
};
getCommandTest();
var getCommandArgumentTest = function() {
var cliArgument = smartcli.get.commandArgument(1);
var cliArgument2 = smartcli.get.commandArgument(2);
if(cliArgument.name == "jam") {
beautylog.success('The first specified command argument name is "jam". Perfect!');
} else {
beautylog.error('The first specified command argument name is not "jam". Something is wrong!');
process.exit(1);
}
if(cliArgument2.name == "undefined") {
beautylog.success('The second specified command argument name is "undefined". Perfect!');
} else {
beautylog.error('The second specified command argument name is not "undefined". Something is wrong!');
process.exit(1);
}
};
getCommandArgumentTest();
var getCommandArgsTest = function() {
var commandArgs = smartcli.get.commandArgs();
if(commandArgs[0].name == "jam") {
beautylog.success("first command argument is 'jam'. Perfect!");
} else {
beautylog.error("first command argument is not 'jam'. Something is wromg!");
console.log(commandArgs[0].name);
process.exit(1);
}
};
getCommandArgsTest();
var getOptionTest = function() {
var cliOption = smartcli.get.option("awesome");
var cliOption2 = smartcli.get.option("terrific");
if(cliOption.specified){
beautylog.success("awesome is specified. Perfect!")
} else {
beautylog.error("awesome is not specified. Somehthing is wrong");
process.exit(1);
}
if(!cliOption2.specified){
beautylog.success("terrific is not specified. Perfect!")
} else {
beautylog.error("terrific is specified. Somehthing is wrong");
process.exit(1);
}
};
getOptionTest();
var getCwdTest = function(){
beautylog.info('The current directory is: ' + smartcli.get.cwd().path);
};
getCwdTest();
/* ------------------------------------------------------------------ *
* ------------------- INTERACTION TESTS ---------------------------- *
* ------------------------------------------------------------------ */
var interactionGetAnswerTest = function() {
smartcli.interaction.getAnswer('How do you feel?',function(answer){
console.log('The answer is: ' + answer);
interactionGetChoiceTest();
});
};
var interactionGetChoiceTest = function() {
smartcli.interaction.getChoice('What music do you like to hear?',['Jazz','Blues','Classical'],function(answer){
console.log('The answer is: ' + answer);
endTests();
});
};
var endTests = function() {
beautylog.ok("No more tests!");
beautylog.success("Tests completed successfully!");
};
if(!smartcli.check.option("silent")){
interactionGetAnswerTest();
} else {
beautylog.info("--silent option is specified, thus we are not running interaction tests.");
endTests();
};

View File

@ -1,33 +1,4 @@
import "typings-global"; 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";
import {Smartcli} from "./smartcli.classes.smartcli"; import {Smartcli} from "./smartcli.classes.smartcli";
export {Smartcli} from "./smartcli.classes.smartcli"; export {Smartcli} from "./smartcli.classes.smartcli";
/* ------------------------------------------------ *
* ---------- plugins for direct use -------------- *
* ------------------------------------------------ */
export let commander = plugins.commander; //commander allows cool chaining of cli actions
export let inquirer = plugins.inquirer; //inquirer is for asking questions
export let cliff = plugins.cliff; // formats cli output
export let argv = plugins.argv; //argv gets initial cli commands and options.
/* ------------------------------------------------ *
* ---------- checks ------------------------------ *
* ------------------------------------------------ */
export let check = SmartcliChecks;
/* ------------------------------------------------ *
* ---------- getters ----------------------------- *
* ------------------------------------------------ */
export let get = SmartcliGetters;
/* ------------------------------------------------ *
* ---------- interaction ----------------------------- *
* ------------------------------------------------ */
export let interaction = SmartcliInteractions;

View File

@ -3,28 +3,6 @@ import "typings-global";
import "./smartcli.interfaces"; import "./smartcli.interfaces";
import plugins = require("./smartcli.plugins"); import plugins = require("./smartcli.plugins");
/**
* checks for a special command string and returns true if found.
* @param commandString
* @returns {boolean}
*/
export let command = function(commandString:string):boolean {
if (plugins.argv._.indexOf(commandString) == 0) {
return true
}
return false;
};
/**
* checks if a command is present, returns true if yes, false if no.
* @returns {boolean}
*/
export let commandPresence = function():boolean {
if(plugins.argv._.length > 0){
return true;
}
return false;
};
/** /**
* checks for an special command argument at a certain position, returns true if matches, returns false if not * checks for an special command argument at a certain position, returns true if matches, returns false if not

View File

@ -1,5 +1,35 @@
import "typings-global"; 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 { export class Smartcli {
questionsDone;
commands:interfaces.CliCommand[];
questions;
constructor(){
this.questionsDone = plugins.q.defer();
}
addCommand(definitionArg:{commandName:string}){
let done = plugins.q.defer();
if (plugins.argv._.indexOf(definitionArg.commandName) == 0) {
done.resolve();
} else {
return done.reject();
}
return done.promsise;
};
addQuestion(definitionArg:{questionString:string,questionType:string}){
};
addVersion(versionArg:string){
}
startParse(){
}
} }

View File

@ -4,19 +4,6 @@ import * as interfaces from "./smartcli.interfaces";
import plugins = require("./smartcli.plugins"); import plugins = require("./smartcli.plugins");
import SmartcliChecks = require("./smartcli.checks"); import SmartcliChecks = require("./smartcli.checks");
/**
*
* @param commandString
* @returns {{specified: boolean, name: any, arguments: CliCommandArgument}}
*/
export let command = function():interfaces.CliCommand {
var cliCommand = {
specified: SmartcliChecks.commandPresence(),
name: plugins.argv._[0],
arguments: commandArgs()
}
return cliCommand;
};
/** /**
* gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument * gets the second or higher value of plugins.argv._ if specified and returns it as commandArgument

View File

@ -15,7 +15,7 @@ export let getAnswer = function(questionString:string, cb) {
return null; return null;
} }
//make inquirer compatible question object //make inquirer compatible question object
var question = { let question = {
type: "input", type: "input",
name: "userFeedback", name: "userFeedback",
message: questionString, message: questionString,
@ -25,7 +25,7 @@ export let getAnswer = function(questionString:string, cb) {
}; };
plugins.inquirer.prompt([question],function(answers){ plugins.inquirer.prompt([question],function(answers){
var answer = answers.userFeedback; let answer = answers.userFeedback;
cb(answer); cb(answer);
}); });
}; };
@ -43,7 +43,7 @@ export let getChoice = function(questionString:string, choiceOptions:string[], c
} }
//make inquirer compatible question object //make inquirer compatible question object
var question = { let question = {
type: "list", type: "list",
name: "userFeedback", name: "userFeedback",
message: questionString, message: questionString,
@ -52,7 +52,7 @@ export let getChoice = function(questionString:string, choiceOptions:string[], c
}; };
plugins.inquirer.prompt(question,function(answers){ plugins.inquirer.prompt(question,function(answers){
var answer = answers.userFeedback; let answer = answers.userFeedback;
cb(answer); cb(answer);
}); });

View File

@ -1,5 +1,11 @@
import "typings-global"; import "typings-global";
export interface CliCommand {
specified: boolean;
name: string;
arguments:CliCommandArgument[];
}
export interface CliOption { export interface CliOption {
name: string; name: string;
specified:boolean; specified:boolean;
@ -10,12 +16,6 @@ export interface Directory {
path: string; path: string;
} }
export interface CliCommand {
specified: boolean;
name: string;
arguments:CliCommandArgument[];
}
export interface CliCommandArgument { export interface CliCommandArgument {
specified:boolean; specified:boolean;
name:string; name:string;

View File

@ -1,9 +1,9 @@
import "typings-global"; import "typings-global";
export let path = require("path"); export let argv = require('yargs').argv;
export let beautylog = require("beautylog"); export let beautylog = require("beautylog");
export let cliff = require("cliff"); export let cliff = require("cliff");
export let commander = require("commander");
export let inquirer = require("inquirer"); export let inquirer = require("inquirer");
export let path = require("path");
export let q = require("q");
export let smartparam = require("smartparam"); export let smartparam = require("smartparam");
export let argv = require('yargs').argv;