Add PromptObject Return to Prompt Function (#38245)

This commit is contained in:
Gheorghe
2019-09-25 15:53:49 -07:00
committed by Ben Lichtman
parent 80c6d50779
commit b3f478f123
2 changed files with 20 additions and 3 deletions
+8 -3
View File
@@ -1,8 +1,9 @@
// Type definitions for vorpal 1.11
// Type definitions for vorpal 1.12
// Project: https://github.com/dthree/vorpal
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Gheorghe Avram <https://github.com/sweethuman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 3.5
declare class Vorpal {
parse(argv: ReadonlyArray<string>): this;
@@ -34,6 +35,10 @@ declare namespace Vorpal {
};
}
interface PromptObject {
[key: string]: any;
}
type Action = (args: Args) => Promise<void>;
type Cancel = () => void;
@@ -74,7 +79,7 @@ declare namespace Vorpal {
class CommandInstance {
log(value: string, ...values: string[]): void;
prompt(prompt: object | ReadonlyArray<object>): Promise<object>;
prompt(prompt: object | ReadonlyArray<object>): Promise<PromptObject>;
delimiter(value: string): void;
}
}
+12
View File
@@ -10,6 +10,18 @@ vorpal
vorpal.log('bar');
return Promise.resolve();
});
vorpal
.command('input', 'Test Prompt Function')
.action(async (action) => {
const promptInput = await vorpal.activeCommand.prompt([
{
type: 'input',
name: 'exampleInput',
message: 'Please Input Something',
}
]);
vorpal.log(promptInput.exampleInput);
});
vorpal
.delimiter('myapp$')