input.form
Prompts the user with a form using Enquirer and returns the collected responses.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
option | Object | Configuration for the form prompt, including key, question, and field definitions. Properties
|
Returns:
The user's responses to the form fields.
- Type:
- Promise.<Object>
Example
import { input } from "@jlongyam/cli";
let result = await input.form({
key: 'data',
question: 'Please provide the following information:',
field: [
{ name: 'package', message: 'Package name', initial: 'test' },
{ name: 'version', message: 'Version', initial: '1.0.0' },
{ name: 'main', message: 'Main script', initial: 'index.js' },
{ name: 'type', message: 'Script type', initial: 'module' }
]
});
console.table(result.data);