smartinteract/dist/smartinteract.classes.smartinteract.d.ts

72 lines
1.8 KiB
TypeScript
Raw Normal View History

2016-11-20 00:11:22 +00:00
/// <reference types="q" />
import * as q from 'q';
2016-11-20 21:24:09 +00:00
import { Objectmap } from 'lik';
2016-11-20 00:11:22 +00:00
export declare type questionType = 'input' | 'confirm' | 'list' | 'rawlist' | 'expand' | 'checkbox' | 'password' | 'editor';
export interface IChoiceObject {
name: string;
value: any;
}
export interface IQuestionObject {
name: string;
type: questionType;
message: string;
default: any;
2016-11-20 21:24:09 +00:00
choices?: string[] | IChoiceObject[];
validate?: IValidateFunction;
2016-11-20 00:11:22 +00:00
}
export interface IAnswerObject {
2016-11-20 21:24:09 +00:00
name: string;
value: any;
2016-11-20 00:11:22 +00:00
}
export interface IValidateFunction {
(anyObject: any): boolean;
}
/**
* class SmartInteract - allows to specify an user interaction during runtime
*/
export declare class SmartInteract {
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap;
/**
* constructor of class SmartInteract
*/
constructor(questionArrayArg?: IQuestionObject[]);
/**
* allows you to ask a single question and returns the answer in a promise
* skips the queue
*/
2016-11-20 21:24:09 +00:00
askQuestion(optionsArg: IQuestionObject): q.Promise<IAnswerObject>;
2016-11-20 00:11:22 +00:00
/**
* add questions to queue
*/
addQuestions(questionArrayArg: IQuestionObject[]): void;
/**
* run the question queue
*/
2016-11-20 21:24:09 +00:00
runQueue(): q.Promise<AnswerBucket>;
/**
* checks if the current env is valid for userinput
*/
private isValidEnv();
}
/**
* class AnswerBucket holds answers
*/
export declare class AnswerBucket {
answerMap: Objectmap<IAnswerObject>;
/**
* add an answer to the bucket
*/
addAnswer(answerArg: IAnswerObject): void;
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg: string): any;
/**
* gets all answers as array
*/
getAllAnswers(): IAnswerObject[];
2016-11-20 00:11:22 +00:00
}