mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Add PromptObject Return to Prompt Function (#38245)
This commit is contained in:
Vendored
+8
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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$')
|
||||
|
||||
Reference in New Issue
Block a user