2016-06-10 00:27:04 +00:00
|
|
|
import "typings-global";
|
|
|
|
|
2016-06-10 01:10:21 +00:00
|
|
|
import * as plugins from "./smartcli.plugins"
|
|
|
|
import * as SmartcliInteractions from "./smartcli.interaction";
|
|
|
|
|
2016-06-10 00:27:04 +00:00
|
|
|
export class Smartcli {
|
2016-06-10 01:48:01 +00:00
|
|
|
argv;
|
2016-06-10 01:10:21 +00:00
|
|
|
questionsDone;
|
2016-06-10 01:48:01 +00:00
|
|
|
parseStarted;
|
|
|
|
commands;
|
2016-06-10 01:10:21 +00:00
|
|
|
questions;
|
2016-06-10 01:48:01 +00:00
|
|
|
version:string;
|
2016-06-10 01:10:21 +00:00
|
|
|
constructor(){
|
2016-06-10 01:48:01 +00:00
|
|
|
this.argv = plugins.argv;
|
2016-06-10 01:10:21 +00:00
|
|
|
this.questionsDone = plugins.q.defer();
|
2016-06-10 01:48:01 +00:00
|
|
|
this.parseStarted = plugins.q.defer();
|
2016-06-10 01:10:21 +00:00
|
|
|
}
|
2016-06-10 01:48:01 +00:00
|
|
|
addAlias(keyArg,aliasArg){
|
|
|
|
this.argv = this.argv.alias(keyArg,aliasArg);
|
|
|
|
};
|
2016-06-10 01:10:21 +00:00
|
|
|
addCommand(definitionArg:{commandName:string}){
|
|
|
|
let done = plugins.q.defer();
|
2016-06-10 01:48:01 +00:00
|
|
|
this.parseStarted
|
|
|
|
.then(() => {
|
|
|
|
if (this.argv._.indexOf(definitionArg.commandName) == 0) {
|
|
|
|
done.resolve();
|
|
|
|
} else {
|
|
|
|
return done.reject();
|
|
|
|
}
|
|
|
|
});
|
2016-06-10 01:10:21 +00:00
|
|
|
return done.promsise;
|
|
|
|
};
|
|
|
|
addQuestion(definitionArg:{questionString:string,questionType:string}){
|
|
|
|
|
|
|
|
};
|
|
|
|
addVersion(versionArg:string){
|
2016-06-10 01:48:01 +00:00
|
|
|
this.version = versionArg;
|
|
|
|
this.parseStarted
|
|
|
|
.then(() => {
|
2016-06-10 01:10:21 +00:00
|
|
|
|
2016-06-10 01:48:01 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
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;
|
2016-06-10 01:10:21 +00:00
|
|
|
}
|
|
|
|
startParse(){
|
2016-06-10 01:48:01 +00:00
|
|
|
this.parseStarted.resolve();
|
2016-06-10 01:10:21 +00:00
|
|
|
}
|
|
|
|
|
2016-06-09 12:01:06 +00:00
|
|
|
}
|