[yargs-interactive] Update type definition to v2.1 (#37181)

This commit is contained in:
Mariano Vazquez 2019-08-01 21:40:10 -03:00 committed by Jesse Trinity
parent edceaaaa64
commit 247dcd9f19
2 changed files with 25 additions and 17 deletions

View File

@ -1,17 +1,18 @@
// Type definitions for yargs-interactive 2.0
// Type definitions for yargs-interactive 2.1
// Project: https://github.com/nanovazquez/yargs-interactive#readme
// Definitions by: Steven Zeck <https://github.com/szeck87>
// Nano Vazquez <https://github.com/nanovazquez>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function yargsInteractive(): yargsInteractive.Interactive;
declare namespace yargsInteractive {
interface OptionData {
type: string;
type: 'input' | 'number' | 'confirm' | 'list' | 'rawlist' | 'expand' | 'checkbox' | 'password' | 'editor';
describe: string;
default?: string | number | boolean;
prompt?: string;
options?: string[];
default?: string | number | boolean | any[];
prompt?: 'always' | 'never' | 'if-no-arg' | 'if-empty';
choices?: string[];
}
interface Option {
[key: string]: OptionData | { default: boolean };

View File

@ -1,19 +1,26 @@
/// <reference types="node" />
import yargsInteractive = require("yargs-interactive");
import yargsInteractive = require('yargs-interactive');
const options: yargsInteractive.Option = {
color: {
describe: "What is your favorite color?",
prompt: "always",
type: "input",
default: "Blue",
}
name: {
describe: 'What is your name?',
prompt: 'always',
type: 'input',
default: 'Nano',
},
color: {
describe: 'What is your favorite color?',
prompt: 'always',
type: 'list',
choices: ['Blue', 'Red', 'Yellow'],
default: 'Blue',
},
};
yargsInteractive()
.usage("$0 <command> [args]")
.interactive(options)
.then((result: any) => {
console.log(result);
});
.usage('$0 <command> [args]')
.interactive(options)
.then((result: any) => {
console.log(result);
});