Compare commits

..

15 Commits

Author SHA1 Message Date
7f2dab091f 1.0.14 2016-11-19 15:02:29 +01:00
dd293875c4 improve README 2016-11-19 15:02:24 +01:00
120eca42ac 1.0.13 2016-11-19 13:43:33 +01:00
fc289616f6 1.0.12 2016-11-19 13:43:10 +01:00
e7c1c1c45b cleanup 2016-11-19 13:43:06 +01:00
f33c759fa8 improve README 2016-10-15 02:12:10 +02:00
1185df362b update test file 2016-10-15 01:06:36 +02:00
36de8e11f0 1.0.11 2016-10-15 01:01:25 +02:00
74ffb3aa87 update deps 2016-10-15 01:01:22 +02:00
96a6d01720 1.0.10 2016-10-15 00:56:05 +02:00
7833bd0be8 implement standardJS 2016-10-15 00:56:02 +02:00
7ca18c4a46 1.0.9 2016-09-04 17:50:36 +02:00
b98e2a1a62 improve typings 2016-09-04 17:50:10 +02:00
e102203422 1.0.8 2016-09-04 17:36:19 +02:00
92a37cf29b fix ci 2016-09-04 17:36:07 +02:00
20 changed files with 185 additions and 317 deletions

View File

@ -40,7 +40,7 @@ pages:
image: hosttoday/ht-docker-node:npmpage image: hosttoday/ht-docker-node:npmpage
stage: page stage: page
script: script:
- npmci command npmts - npmci test stable
- npmci command npmpage --host gitlab - npmci command npmpage --host gitlab
only: only:
- tags - tags

View File

View File

@ -35,7 +35,7 @@ mytool function argument1 argument2 --option1 -o2 option2Value
* option1 is a longform option you can add (like --message for message) * option1 is a longform option you can add (like --message for message)
* optionValue is the referenced option value (like a commit message) * optionValue is the referenced option value (like a commit message)
```typescript ```javascript
import {Smartcli} from "smartcli" import {Smartcli} from "smartcli"
mySmartcli = new Smartcli(); mySmartcli = new Smartcli();
mySmartcli.standardTask() mySmartcli.standardTask()
@ -43,5 +43,18 @@ mySmartcli.standardTask()
// do something if program is called without an command // do something if program is called without an command
}); });
mySmartcli.question mySmartcli.addCommand({commandname: 'install'})
``` .then(argvArg => {
// do something if program is called with command "install"
})
mySmartcli.addVersion('1.0.0') // -v and --version options will display the specified version in the terminal
mySmartCli.addHelp({ // is triggered by help command and --help option
helpText: 'some help text to print' // the helpText to display
})
mySmartcli.startParse() // starts the evaluation and fullfills or rejects promises.
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

3
dist/index.d.ts vendored
View File

@ -1,2 +1 @@
import "typings-global"; export { Smartcli } from './smartcli.classes.smartcli';
export { Smartcli } from "./smartcli.classes.smartcli";

3
dist/index.js vendored
View File

@ -1,5 +1,4 @@
"use strict"; "use strict";
require("typings-global");
var smartcli_classes_smartcli_1 = require("./smartcli.classes.smartcli"); var smartcli_classes_smartcli_1 = require("./smartcli.classes.smartcli");
exports.Smartcli = smartcli_classes_smartcli_1.Smartcli; exports.Smartcli = smartcli_classes_smartcli_1.Smartcli;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBR3hCLDBDQUF1Qiw2QkFBNkIsQ0FBQztBQUE3Qyx3REFBNkMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEseUVBQXNEO0FBQTdDLCtDQUFBLFFBQVEsQ0FBQSJ9

View File

@ -1,32 +0,0 @@
import "typings-global";
/**
* allows to specify an user interaction during runtime
*/
export declare type questionType = "input" | "confirm" | "list" | "rawlist" | "expand" | "checkbox" | "password" | "editor";
export interface choiceObject {
name: string;
value: any;
}
export interface validateFunction {
(any: any): boolean;
}
export declare class Interaction {
constructor();
askQuestion(optionsArg: {
type: questionType;
message: string;
default: any;
choices: string[] | choiceObject[];
validate: validateFunction;
}): void;
askQuestionArray: any;
}
export declare class QuestionTree {
constructor(questionString: string, optionsArray: any);
}
export declare class QuestionTreeNode {
constructor();
}
export declare class QuestionStorage {
constructor();
}

View File

@ -1,41 +0,0 @@
"use strict";
require("typings-global");
const plugins = require("./smartcli.plugins");
class Interaction {
constructor() {
}
;
askQuestion(optionsArg) {
let done = plugins.q.defer();
plugins.inquirer.prompt([{
type: optionsArg.type,
message: optionsArg.message,
default: optionsArg.default,
choices: optionsArg.choices,
validate: optionsArg.validate
}]).then(answers => {
done.resolve(answers);
});
}
;
}
exports.Interaction = Interaction;
class QuestionTree {
constructor(questionString, optionsArray) {
}
;
}
exports.QuestionTree = QuestionTree;
;
class QuestionTreeNode {
constructor() {
}
}
exports.QuestionTreeNode = QuestionTreeNode;
;
class QuestionStorage {
constructor() {
}
}
exports.QuestionStorage = QuestionStorage;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5pbnRlcmFjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuaW50ZXJhY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixNQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBZTlDO0lBQ0k7SUFDQSxDQUFDOztJQUVELFdBQVcsQ0FBQyxVQU1YO1FBQ0csSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDO2dCQUNyQixJQUFJLEVBQUUsVUFBVSxDQUFDLElBQUk7Z0JBQ3JCLE9BQU8sRUFBRSxVQUFVLENBQUMsT0FBTztnQkFDM0IsT0FBTyxFQUFFLFVBQVUsQ0FBQyxPQUFPO2dCQUMzQixPQUFPLEVBQUMsVUFBVSxDQUFDLE9BQU87Z0JBQzFCLFFBQVEsRUFBRSxVQUFVLENBQUMsUUFBUTthQUNoQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTztZQUNaLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDMUIsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDOztBQUVMLENBQUM7QUF2QlksbUJBQVcsY0F1QnZCLENBQUE7QUFHRDtJQUVJLFlBQVksY0FBc0IsRUFBRSxZQUFZO0lBRWhELENBQUM7O0FBQ0wsQ0FBQztBQUxZLG9CQUFZLGVBS3hCLENBQUE7QUFBQSxDQUFDO0FBRUY7SUFDSTtJQUVBLENBQUM7QUFDTCxDQUFDO0FBSlksd0JBQWdCLG1CQUk1QixDQUFBO0FBQUEsQ0FBQztBQUVGO0lBQ0k7SUFFQSxDQUFDO0FBQ0wsQ0FBQztBQUpZLHVCQUFlLGtCQUkzQixDQUFBIn0=

View File

@ -1,10 +1,9 @@
/// <reference types="q" /> /// <reference types="q" />
import "typings-global"; import * as q from 'q';
import * as plugins from "./smartcli.plugins"; import { Objectmap } from 'lik';
import { Objectmap } from "lik"; export interface ICommandPromiseObject {
export interface commandPromiseObject {
commandName: string; commandName: string;
promise: plugins.q.Promise<any>; promise: q.Promise<any>;
} }
export declare class Smartcli { export declare class Smartcli {
argv: any; argv: any;
@ -13,7 +12,7 @@ export declare class Smartcli {
commands: any; commands: any;
questions: any; questions: any;
version: string; version: string;
allCommandPromises: Objectmap<commandPromiseObject>; allCommandPromises: Objectmap<ICommandPromiseObject>;
constructor(); constructor();
/** /**
* adds an alias, meaning one equals the other in terms of triggering associated commands * adds an alias, meaning one equals the other in terms of triggering associated commands
@ -21,16 +20,15 @@ export declare class Smartcli {
addAlias(keyArg: any, aliasArg: any): void; addAlias(keyArg: any, aliasArg: any): void;
/** /**
* adds a Command by returning a Promise that reacts to the specific commandString given. * adds a Command by returning a Promise that reacts to the specific commandString given.
*
* Note: in e.g. "npm install something" the "install" is considered the command. * Note: in e.g. "npm install something" the "install" is considered the command.
*/ */
addCommand(definitionArg: { addCommand(definitionArg: {
commandName: string; commandName: string;
}): plugins.q.Promise<{}>; }): q.Promise<any>;
/** /**
* gets a Promise for a command word * gets a Promise for a command word
*/ */
getCommandPromiseByName(commandNameArg: string): plugins.q.Promise<any>; getCommandPromiseByName(commandNameArg: string): q.Promise<any>;
/** /**
* allows to specify help text to be printed above the rest of the help text * allows to specify help text to be printed above the rest of the help text
*/ */
@ -44,7 +42,7 @@ export declare class Smartcli {
/** /**
* returns promise that is resolved when no commands are specified * returns promise that is resolved when no commands are specified
*/ */
standardTask(): plugins.q.Promise<{}>; standardTask(): q.Promise<any>;
/** /**
* start the process of evaluating commands * start the process of evaluating commands
*/ */

View File

@ -1,35 +1,32 @@
"use strict"; "use strict";
require("typings-global"); const q = require("q");
const plugins = require("./smartcli.plugins"); const plugins = require("./smartcli.plugins");
// import classes // import classes
const lik_1 = require("lik"); const lik_1 = require("lik");
;
class Smartcli { class Smartcli {
constructor() { constructor() {
// maps // maps
this.allCommandPromises = new lik_1.Objectmap(); this.allCommandPromises = new lik_1.Objectmap();
this.argv = plugins.yargs; this.argv = plugins.yargs;
this.questionsDone = plugins.q.defer(); this.questionsDone = q.defer();
this.parseStarted = plugins.q.defer(); this.parseStarted = q.defer();
} }
;
/** /**
* adds an alias, meaning one equals the other in terms of triggering associated commands * adds an alias, meaning one equals the other in terms of triggering associated commands
*/ */
addAlias(keyArg, aliasArg) { addAlias(keyArg, aliasArg) {
this.argv = this.argv.alias(keyArg, aliasArg); this.argv = this.argv.alias(keyArg, aliasArg);
return;
} }
;
/** /**
* adds a Command by returning a Promise that reacts to the specific commandString given. * adds a Command by returning a Promise that reacts to the specific commandString given.
*
* Note: in e.g. "npm install something" the "install" is considered the command. * Note: in e.g. "npm install something" the "install" is considered the command.
*/ */
addCommand(definitionArg) { addCommand(definitionArg) {
let done = plugins.q.defer(); let done = q.defer();
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if (this.argv._.indexOf(definitionArg.commandName) == 0) { if (this.argv._.indexOf(definitionArg.commandName) === 0) {
done.resolve(this.argv); done.resolve(this.argv);
} }
else { else {
@ -38,7 +35,6 @@ class Smartcli {
}); });
return done.promise; return done.promise;
} }
;
/** /**
* gets a Promise for a command word * gets a Promise for a command word
*/ */
@ -47,24 +43,22 @@ class Smartcli {
return commandPromiseObjectArg.commandName === commandNameArg; return commandPromiseObjectArg.commandName === commandNameArg;
}).promise; }).promise;
} }
;
/** /**
* allows to specify help text to be printed above the rest of the help text * allows to specify help text to be printed above the rest of the help text
*/ */
addHelp(optionsArg) { addHelp(optionsArg) {
this.addCommand({ this.addCommand({
commandName: "help" commandName: 'help'
}).then(argvArg => { }).then(argvArg => {
plugins.beautylog.log(optionsArg.helpText); plugins.beautylog.log(optionsArg.helpText);
}); });
} }
;
/** /**
* specify version to be printed for -v --version * specify version to be printed for -v --version
*/ */
addVersion(versionArg) { addVersion(versionArg) {
this.version = versionArg; this.version = versionArg;
this.addAlias("v", "version"); this.addAlias('v', 'version');
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if (this.argv.v) { if (this.argv.v) {
@ -72,21 +66,19 @@ class Smartcli {
} }
}); });
} }
;
/** /**
* returns promise that is resolved when no commands are specified * returns promise that is resolved when no commands are specified
*/ */
standardTask() { standardTask() {
let done = plugins.q.defer(); let done = q.defer();
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if (this.argv._.length == 0 && !this.argv.v) { if (this.argv._.length === 0 && !this.argv.v) {
done.resolve(this.argv); done.resolve(this.argv);
} }
else { else {
done.reject(this.argv); done.reject(this.argv);
} }
;
}); });
return done.promise; return done.promise;
} }
@ -96,7 +88,8 @@ class Smartcli {
startParse() { startParse() {
this.argv = this.argv.argv; this.argv = this.argv.argv;
this.parseStarted.resolve(); this.parseStarted.resolve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RQUMzQixNQUFNLENBQUE7SUFDVixDQUFDO0NBRUo7QUF0R0QsNEJBc0dDIn0=

View File

@ -1,9 +1,7 @@
import "typings-global"; import 'typings-global';
export import yargs = require('yargs'); import * as yargs from 'yargs';
export import beautylog = require("beautylog"); import * as beautylog from 'beautylog';
export import cliff = require("cliff"); import * as lik from 'lik';
export import inquirer = require("inquirer"); import * as path from 'path';
export import lik = require("lik"); import * as smartparam from 'smartparam';
export import path = require("path"); export { yargs, beautylog, lik, path, smartparam };
export import q = require("q");
export import smartparam = require("smartparam");

View File

@ -1,11 +1,13 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
exports.yargs = require('yargs'); const yargs = require("yargs");
exports.beautylog = require("beautylog"); exports.yargs = yargs;
exports.cliff = require("cliff"); const beautylog = require("beautylog");
exports.inquirer = require("inquirer"); exports.beautylog = beautylog;
exports.lik = require("lik"); const lik = require("lik");
exports.path = require("path"); exports.lik = lik;
exports.q = require("q"); const path = require("path");
exports.smartparam = require("smartparam"); exports.path = path;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUVWLGFBQUssV0FBVyxPQUFPLENBQUMsQ0FBQztBQUN6QixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGFBQUssV0FBVyxPQUFPLENBQUMsQ0FBQztBQUN6QixnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFdBQUcsV0FBVyxLQUFLLENBQUMsQ0FBQztBQUNyQixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsU0FBQyxXQUFXLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGtCQUFVLFdBQVcsWUFBWSxDQUFDLENBQUMifQ== const smartparam = require("smartparam");
exports.smartparam = smartparam;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF3QjtBQUV4QiwrQkFBOEI7QUFPMUIsc0JBQUs7QUFOVCx1Q0FBc0M7QUFPbEMsOEJBQVM7QUFOYiwyQkFBMEI7QUFPdEIsa0JBQUc7QUFOUCw2QkFBNEI7QUFPeEIsb0JBQUk7QUFOUix5Q0FBd0M7QUFPcEMsZ0NBQVUifQ==

View File

@ -1,6 +1,6 @@
{ {
"name": "smartcli", "name": "smartcli",
"version": "1.0.7", "version": "1.0.14",
"description": "nodejs wrapper for CLI related tasks", "description": "nodejs wrapper for CLI related tasks",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -28,22 +28,19 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartcli", "homepage": "https://gitlab.com/pushrocks/smartcli",
"dependencies": { "dependencies": {
"@types/cliff": "^0.1.3",
"@types/inquirer": "0.x.x",
"@types/q": "0.x.x", "@types/q": "0.x.x",
"@types/yargs": "0.x.x", "@types/yargs": "6.x.x",
"beautylog": "^5.0.20", "beautylog": "^6.0.0",
"cliff": "^0.1.10", "lik": "^1.0.24",
"inquirer": "^1.1.2",
"lik": "^1.0.15",
"q": "^1.4.1", "q": "^1.4.1",
"smartparam": "0.1.1", "smartparam": "0.1.1",
"typings-global": "^1.0.6", "typings-global": "^1.0.14",
"yargs": "^5.0.0" "yargs": "^6.4.0"
}, },
"devDependencies": { "devDependencies": {
"@types/should": "^8.1.30",
"npmts-g": "^5.2.8", "npmts-g": "^5.2.8",
"should": "^11.1.0", "should": "^11.1.1",
"typings-test": "^1.0.1" "typings-test": "^1.0.3"
} }
} }

2
test/test.d.ts vendored
View File

@ -1 +1 @@
import "typings-test"; import 'typings-test';

View File

@ -1,36 +1,35 @@
"use strict"; "use strict";
require("typings-test"); require("typings-test");
const smartcli = require("../dist/index"); const smartcli = require("../dist/index");
let beautylog = require("beautylog"); const should = require("should");
let should = require("should"); describe('smartcli.Smartcli class', function () {
describe("smartcli.Smartcli class", function () {
let smartCliTestObject; let smartCliTestObject;
describe("new Smartcli()", function () { describe('new Smartcli()', function () {
it("should create a new Smartcli", function () { it('should create a new Smartcli', function () {
smartCliTestObject = new smartcli.Smartcli(); smartCliTestObject = new smartcli.Smartcli();
smartCliTestObject.should.be.instanceof(smartcli.Smartcli); should(smartCliTestObject).be.instanceof(smartcli.Smartcli);
}); });
}); });
describe(".addCommand", function () { describe('.addCommand', function () {
it("should add an command", function () { it('should add an command', function () {
smartCliTestObject.addCommand({ smartCliTestObject.addCommand({
commandName: "awesome" commandName: 'awesome'
}); });
}); });
}); });
describe(".standardTask", function () { describe('.standardTask', function () {
it("should start parsing a standardTask", function (done) { it('should start parsing a standardTask', function (done) {
smartCliTestObject.standardTask() smartCliTestObject.standardTask()
.then(() => { .then(() => {
console.log("this is the standard Task!"); console.log('this is the standard Task!');
}); });
done(); done();
}); });
}); });
describe(".startParse", function () { describe('.startParse', function () {
it("should start parsing the CLI input", function () { it('should start parsing the CLI input', function () {
smartCliTestObject.startParse(); smartCliTestObject.startParse();
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFFdEIsTUFBTyxRQUFRLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDM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BQUU7aUJBQzVCLElBQUksQ0FBQztnQkFDRixPQUFPLENBQUMsR0FBRyxDQUFDLDRCQUE0QixDQUFDLENBQUE7WUFDN0MsQ0FBQyxDQUFDLENBQUE7WUFDTixJQUFJLEVBQUUsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7SUFDRixRQUFRLENBQUMsYUFBYSxFQUFDO1FBQ25CLEVBQUUsQ0FBQyxvQ0FBb0MsRUFBQztZQUNwQyxrQkFBa0IsQ0FBQyxVQUFVLEVBQUUsQ0FBQTtRQUNuQyxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==

View File

@ -1,37 +1,35 @@
import "typings-test"; import 'typings-test'
import smartcli = require("../dist/index"); import smartcli = require('../dist/index')
let beautylog = require("beautylog"); import * as should from 'should'
let should = require("should");
describe("smartcli.Smartcli class",function(){ describe('smartcli.Smartcli class',function(){
let smartCliTestObject:smartcli.Smartcli; let smartCliTestObject: smartcli.Smartcli
describe("new Smartcli()",function(){ describe('new Smartcli()',function(){
it("should create a new Smartcli",function(){ it('should create a new Smartcli',function(){
smartCliTestObject = new smartcli.Smartcli(); smartCliTestObject = new smartcli.Smartcli()
smartCliTestObject.should.be.instanceof(smartcli.Smartcli); should(smartCliTestObject).be.instanceof(smartcli.Smartcli)
}); })
}); })
describe(".addCommand",function(){ describe('.addCommand',function(){
it("should add an command",function(){ it('should add an command',function(){
smartCliTestObject.addCommand({ smartCliTestObject.addCommand({
commandName:"awesome" commandName: 'awesome'
}); })
})
}); })
}); describe('.standardTask',function(){
describe(".standardTask",function(){ it('should start parsing a standardTask',function(done){
it("should start parsing a standardTask",function(done){
smartCliTestObject.standardTask() smartCliTestObject.standardTask()
.then(() => { .then(() => {
console.log("this is the standard Task!"); console.log('this is the standard Task!')
}); })
done(); done()
}) })
}) })
describe(".startParse",function(){ describe('.startParse',function(){
it("should start parsing the CLI input",function(){ it('should start parsing the CLI input',function(){
smartCliTestObject.startParse(); smartCliTestObject.startParse()
}) })
}) })
}); })

View File

@ -1,4 +1 @@
import "typings-global"; export { Smartcli } from './smartcli.classes.smartcli'
import {Smartcli} from "./smartcli.classes.smartcli";
export {Smartcli} from "./smartcli.classes.smartcli";

View File

@ -1,60 +0,0 @@
import "typings-global";
import * as plugins from "./smartcli.plugins";
/**
* allows to specify an user interaction during runtime
*/
export type questionType = "input" | "confirm" | "list" | "rawlist" | "expand" | "checkbox" | "password" | "editor"
export interface choiceObject {
name: string;
value: any
}
export interface validateFunction {
(any):boolean
}
export class Interaction {
constructor() {
};
askQuestion(optionsArg: {
type: questionType,
message: string
default: any
choices: string[] | choiceObject[];
validate: validateFunction
}) {
let done = plugins.q.defer();
plugins.inquirer.prompt([{
type: optionsArg.type,
message: optionsArg.message,
default: optionsArg.default,
choices:optionsArg.choices,
validate: optionsArg.validate
}]).then(answers => {
done.resolve(answers);
});
};
askQuestionArray
}
export class QuestionTree {
constructor(questionString: string, optionsArray) {
};
};
export class QuestionTreeNode {
constructor() {
}
};
export class QuestionStorage {
constructor() {
}
}

View File

@ -1,116 +1,116 @@
import "typings-global"; import * as q from 'q'
import * as plugins from "./smartcli.plugins"; import * as plugins from './smartcli.plugins'
import * as interaction from "./smartcli.classes.interaction";
// import classes // import classes
import {Objectmap} from "lik"; import {Objectmap} from 'lik'
// interfaces // interfaces
export interface commandPromiseObject { export interface ICommandPromiseObject {
commandName:string; commandName: string
promise: plugins.q.Promise<any>; promise: q.Promise<any>
}; }
export class Smartcli { export class Smartcli {
argv:any; argv: any
questionsDone; questionsDone
parseStarted; parseStarted
commands; commands
questions; questions
version:string; version: string
// maps // maps
allCommandPromises = new Objectmap<commandPromiseObject>(); allCommandPromises = new Objectmap<ICommandPromiseObject>()
constructor(){ constructor() {
this.argv = plugins.yargs; this.argv = plugins.yargs
this.questionsDone = plugins.q.defer(); this.questionsDone = q.defer()
this.parseStarted = plugins.q.defer(); this.parseStarted = q.defer()
}; }
/** /**
* adds an alias, meaning one equals the other in terms of triggering associated commands * adds an alias, meaning one equals the other in terms of triggering associated commands
*/ */
addAlias(keyArg,aliasArg){ addAlias(keyArg,aliasArg): void {
this.argv = this.argv.alias(keyArg,aliasArg); this.argv = this.argv.alias(keyArg,aliasArg)
}; return
}
/** /**
* adds a Command by returning a Promise that reacts to the specific commandString given. * adds a Command by returning a Promise that reacts to the specific commandString given.
*
* Note: in e.g. "npm install something" the "install" is considered the command. * Note: in e.g. "npm install something" the "install" is considered the command.
*/ */
addCommand(definitionArg:{commandName:string}){ addCommand(definitionArg: {commandName: string}): q.Promise<any> {
let done = plugins.q.defer(); let done = q.defer<any>()
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if (this.argv._.indexOf(definitionArg.commandName) == 0) { if (this.argv._.indexOf(definitionArg.commandName) === 0) {
done.resolve(this.argv); done.resolve(this.argv)
} else { } else {
done.reject(this.argv); done.reject(this.argv)
} }
}); })
return done.promise; return done.promise
}; }
/** /**
* gets a Promise for a command word * gets a Promise for a command word
*/ */
getCommandPromiseByName(commandNameArg:string){ getCommandPromiseByName(commandNameArg: string) {
return this.allCommandPromises.find(commandPromiseObjectArg => { return this.allCommandPromises.find(commandPromiseObjectArg => {
return commandPromiseObjectArg.commandName === commandNameArg; return commandPromiseObjectArg.commandName === commandNameArg
}).promise; }).promise
}; }
/** /**
* allows to specify help text to be printed above the rest of the help text * allows to specify help text to be printed above the rest of the help text
*/ */
addHelp(optionsArg:{ addHelp(optionsArg: {
helpText:string helpText: string
}){ }) {
this.addCommand({ this.addCommand({
commandName:"help" commandName: 'help'
}).then(argvArg => { }).then(argvArg => {
plugins.beautylog.log(optionsArg.helpText); plugins.beautylog.log(optionsArg.helpText)
}) })
}; }
/** /**
* specify version to be printed for -v --version * specify version to be printed for -v --version
*/ */
addVersion(versionArg:string){ addVersion(versionArg: string) {
this.version = versionArg; this.version = versionArg
this.addAlias("v","version"); this.addAlias('v','version')
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if(this.argv.v){ if (this.argv.v) {
console.log(this.version); console.log(this.version)
} }
}) })
}; }
/** /**
* returns promise that is resolved when no commands are specified * returns promise that is resolved when no commands are specified
*/ */
standardTask(){ standardTask(): q.Promise<any> {
let done = plugins.q.defer(); let done = q.defer<any>()
this.parseStarted.promise this.parseStarted.promise
.then(() => { .then(() => {
if(this.argv._.length == 0 && !this.argv.v){ if (this.argv._.length === 0 && !this.argv.v) {
done.resolve(this.argv); done.resolve(this.argv)
} else { } else {
done.reject(this.argv); done.reject(this.argv)
}; }
}); })
return done.promise; return done.promise
} }
/** /**
* start the process of evaluating commands * start the process of evaluating commands
*/ */
startParse(){ startParse(): void {
this.argv = this.argv.argv; this.argv = this.argv.argv
this.parseStarted.resolve(); this.parseStarted.resolve()
return
} }
} }

View File

@ -1,10 +1,15 @@
import "typings-global"; import 'typings-global';
export import yargs = require('yargs'); import * as yargs from 'yargs'
export import beautylog = require("beautylog"); import * as beautylog from 'beautylog'
export import cliff = require("cliff"); import * as lik from 'lik'
export import inquirer = require("inquirer"); import * as path from 'path'
export import lik = require("lik"); import * as smartparam from 'smartparam'
export import path = require("path");
export import q = require("q"); export {
export import smartparam = require("smartparam"); yargs,
beautylog,
lik,
path,
smartparam
}

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}