mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
Merge pull request #1427 from danrspencer/master
Added definition file for Promptly
This commit is contained in:
86
promptly/promptly-tests.ts
Normal file
86
promptly/promptly-tests.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
///<reference path="../node/node.d.ts"/>
|
||||
///<reference path="promptly.d.ts"/>
|
||||
|
||||
import promptly = require('promptly');
|
||||
|
||||
process.stdin
|
||||
|
||||
// Options
|
||||
var options: promptly.Options = {}
|
||||
options = {
|
||||
default: 'value'
|
||||
}
|
||||
options = {
|
||||
trim: false
|
||||
}
|
||||
options = {
|
||||
retry: false
|
||||
}
|
||||
options = {
|
||||
silent: false
|
||||
}
|
||||
options = {
|
||||
input: process.stdin
|
||||
}
|
||||
options = {
|
||||
output: process.stdout
|
||||
}
|
||||
|
||||
// Validator
|
||||
options = {
|
||||
validator: () => {}
|
||||
}
|
||||
options = {
|
||||
validator: (value: string) => {}
|
||||
}
|
||||
options = {
|
||||
validator: (value: string) => {
|
||||
return 'result';
|
||||
}
|
||||
}
|
||||
options = {
|
||||
validator: [
|
||||
(value: string) => { return 'result' },
|
||||
(value: string) => { return 'result' }
|
||||
]
|
||||
}
|
||||
|
||||
// Prompt
|
||||
promptly.prompt('hello world');
|
||||
promptly.prompt('hello world', options);
|
||||
promptly.prompt('hello world', () => {
|
||||
|
||||
});
|
||||
promptly.prompt('hello world', options, (err: Error, value: string) => {
|
||||
|
||||
});
|
||||
|
||||
// Password
|
||||
promptly.password('hello world');
|
||||
promptly.password('hello world', options);
|
||||
promptly.password('hello world', () => {
|
||||
|
||||
});
|
||||
promptly.password('hello world', options, (err: Error, value: string) => {
|
||||
|
||||
});
|
||||
|
||||
// Confirm
|
||||
promptly.confirm('hello world');
|
||||
promptly.confirm('hello world', options);
|
||||
promptly.confirm('hello world', () => {
|
||||
|
||||
});
|
||||
promptly.confirm('hello world', options, (err: Error, value: string) => {
|
||||
|
||||
});
|
||||
|
||||
// Choose
|
||||
promptly.choose('hello world', ['test1', 'test2']);
|
||||
promptly.choose('hello world', ['test1', 'test2'], options);
|
||||
promptly.choose('hello world', ['test1', 'test2'], () => {
|
||||
|
||||
});
|
||||
promptly.choose('hello world', ['test1', 'test2'], options, (err: Error, value: string) => {
|
||||
|
||||
});
|
||||
34
promptly/promptly.d.ts
vendored
Normal file
34
promptly/promptly.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Type definitions for node-promptly 1.1.1
|
||||
// Project: https://github.com/IndigoUnited/node-promptly
|
||||
// Definitions by: Dan Spencer <https://github.com/danrspencer>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "promptly" {
|
||||
|
||||
interface Callback {
|
||||
(err: Error, value: string): void;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
default?: string;
|
||||
trim?: boolean;
|
||||
validator?: any;
|
||||
retry?: boolean;
|
||||
silent?: boolean;
|
||||
input?: ReadableStream;
|
||||
output?: WritableStream;
|
||||
}
|
||||
|
||||
export function prompt(message: string, fn?: Callback);
|
||||
export function prompt(message: string, opts: Options, fn?: Callback);
|
||||
|
||||
export function password(message: string, fn?: Callback);
|
||||
export function password(message: string, opts: Options, fn?: Callback);
|
||||
|
||||
export function confirm(message: string, fn?: Callback);
|
||||
export function confirm(message: string, opts: Options, fn?: Callback);
|
||||
|
||||
export function choose(message: string, choices: string[], fn?: Callback);
|
||||
export function choose(message: string, choices: string[], opts: Options, fn?: Callback);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user