mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for cli-interact
This commit is contained in:
parent
adf4e18eef
commit
980bac6265
22
types/cli-interact/cli-interact-tests.ts
Normal file
22
types/cli-interact/cli-interact-tests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import * as cliInteract from 'cli-interact';
|
||||
|
||||
cliInteract.getChar('Tell me one of', 'abcdef');
|
||||
cliInteract.getChoiceByChar('frequency', ['daily', 'weekly', 'monthly']);
|
||||
cliInteract.getChoiceByChar('frequency', ['daily', 'weekly', 'monthly'], true);
|
||||
cliInteract.getChoice('frequency', ['daily', 'weekly', 'monthly']);
|
||||
cliInteract.getChoice('frequency', ['daily', 'weekly', 'monthly'], {
|
||||
returnNumeric: true,
|
||||
});
|
||||
cliInteract.getIPversion(true);
|
||||
cliInteract.getNumber('Case 1: You MAY give me a number: ', {allowNoAnswer: true});
|
||||
cliInteract.getNumber('Case 2: You MUST give me a number: ');
|
||||
cliInteract.getNumber('Case 3: You MUST give me an integer: ', true);
|
||||
cliInteract.getNumber('Case 4: You MAY give me an answer. If you do, it MUST be an integer', {
|
||||
allowNoAnswer: true,
|
||||
requireInteger: true,
|
||||
});
|
||||
cliInteract.getYesNo('Is it true', true);
|
||||
cliInteract.getYesNo('Is it true');
|
||||
cliInteract.question('Tell me what do you want: ', {
|
||||
charlist: 'yn'
|
||||
});
|
||||
27
types/cli-interact/index.d.ts
vendored
Normal file
27
types/cli-interact/index.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Type definitions for cli-interact 0.1
|
||||
// Project: https://github.com/zhami/cli-interact
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { BasicOptions } from 'readline-sync';
|
||||
|
||||
export interface ChoiceOptions {
|
||||
allowNoAnswer?: boolean;
|
||||
returnNumeric?: boolean;
|
||||
}
|
||||
|
||||
export interface NumberOptions {
|
||||
allowNoAnswer?: boolean;
|
||||
requireInteger?: boolean;
|
||||
}
|
||||
|
||||
export function getChar(promptText: string, allowedCharsAsString: string, flagAllowNoAnswer?: boolean): string;
|
||||
export function getChoice(title: string, choices: string[], opts: ChoiceOptions & {returnNumeric: true}): number;
|
||||
export function getChoice(title: string, choices: string[], opts?: ChoiceOptions): string;
|
||||
export function getChoiceByChar(title: string, choices: string[], flagAllowNoAnswer?: boolean): string;
|
||||
export function getInteger(promptText: string): number;
|
||||
export function getIPversion(flagAllowNoAnswer?: boolean): string;
|
||||
export function getNumber(promptText: string, opts?: boolean | NumberOptions): number;
|
||||
export function getYesNo(title: string, flagAllowNoAnswer: true): boolean | undefined;
|
||||
export function getYesNo(title: string, flagAllowNoAnswer?: false): boolean;
|
||||
export function question(prompt: string, options?: BasicOptions): string;
|
||||
23
types/cli-interact/tsconfig.json
Normal file
23
types/cli-interact/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cli-interact-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cli-interact/tslint.json
Normal file
1
types/cli-interact/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user