2016-05-13 23:18:44 +00:00
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
import * as plugins from "./beautylog.plugins";
|
|
|
|
import * as log from "./beautylog.log";
|
|
|
|
|
|
|
|
export class Ora {
|
|
|
|
private _oraObject;
|
|
|
|
state:string;
|
2016-05-14 14:26:38 +00:00
|
|
|
constructor(textArg:string,colorArg:string,startArg:boolean = false){
|
2016-05-13 23:18:44 +00:00
|
|
|
this._oraObject = plugins.ora({
|
|
|
|
spinner:"dots",
|
|
|
|
text:textArg,
|
|
|
|
color:colorArg
|
|
|
|
});
|
2016-05-14 14:26:38 +00:00
|
|
|
|
|
|
|
startArg ? this._oraObject.start() : void(0);
|
2016-05-13 23:18:44 +00:00
|
|
|
}
|
|
|
|
text(textArg){
|
|
|
|
this._oraObject.text = textArg;
|
|
|
|
};
|
2016-05-14 14:26:38 +00:00
|
|
|
|
|
|
|
start(){
|
|
|
|
this._oraObject.start();
|
|
|
|
};
|
2016-05-13 23:18:44 +00:00
|
|
|
end(){
|
|
|
|
this._oraObject.stop();
|
|
|
|
this._oraObject.clear();
|
|
|
|
}
|
|
|
|
endOk(textArg){
|
|
|
|
this.end();
|
|
|
|
log.ok(textArg);
|
|
|
|
};
|
|
|
|
endError(textArg){
|
|
|
|
this.end();
|
|
|
|
log.error(textArg);
|
|
|
|
};
|
2016-05-14 14:26:38 +00:00
|
|
|
stop(){ // alias for end
|
|
|
|
this.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
// log methods that play nice with ora
|
|
|
|
log(logText:string,logType:string){
|
|
|
|
this.stop();
|
|
|
|
log.log(logText,logType);
|
|
|
|
this.start();
|
|
|
|
}
|
2016-05-13 23:18:44 +00:00
|
|
|
}
|