mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
New package: yargs-interactive (#27155)
* Add typings for yargs-interactive * Use require to import yargs-interactive in test
This commit is contained in:
committed by
Ryan Cavanaugh
parent
5f9ef82a75
commit
8ba2ecb239
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for yargs-interactive 2.0
|
||||
// Project: https://github.com/nanovazquez/yargs-interactive#readme
|
||||
// Definitions by: Steven Zeck <https://github.com/szeck87>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function yargsInteractive(): yargsInteractive.Interactive;
|
||||
|
||||
declare namespace yargsInteractive {
|
||||
interface OptionData {
|
||||
type: string;
|
||||
describe: string;
|
||||
default?: string | number | boolean;
|
||||
prompt?: string;
|
||||
options?: string[];
|
||||
}
|
||||
interface Option {
|
||||
[key: string]: OptionData | { default: boolean };
|
||||
}
|
||||
interface Interactive {
|
||||
usage(usage: string): Interactive;
|
||||
interactive(options: Option): Interactive;
|
||||
then(callback: (result: any) => any): Interactive;
|
||||
}
|
||||
}
|
||||
|
||||
export = yargsInteractive;
|
||||
@@ -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",
|
||||
"yargs-interactive-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import yargsInteractive = require("yargs-interactive");
|
||||
|
||||
const options: yargsInteractive.Option = {
|
||||
color: {
|
||||
describe: "What is your favorite color?",
|
||||
prompt: "always",
|
||||
type: "input",
|
||||
default: "Blue",
|
||||
}
|
||||
};
|
||||
|
||||
yargsInteractive()
|
||||
.usage("$0 <command> [args]")
|
||||
.interactive(options)
|
||||
.then((result: any) => {
|
||||
console.log(result);
|
||||
});
|
||||
Reference in New Issue
Block a user