New package: yargs-interactive (#27155)

* Add typings for yargs-interactive

* Use require to import yargs-interactive in test
This commit is contained in:
Steven Zeck
2018-07-12 11:12:45 -07:00
committed by Ryan Cavanaugh
parent 5f9ef82a75
commit 8ba2ecb239
4 changed files with 69 additions and 0 deletions
+26
View File
@@ -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;
+23
View 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",
"yargs-interactive-tests.ts"
]
}
+1
View File
@@ -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);
});