input.form

Prompts the user with a form using Enquirer and returns the collected responses.

Parameters:
NameTypeDescription
optionObject

Configuration for the form prompt, including key, question, and field definitions.

Properties
NameTypeDescription
keystring

The key for the response.

questionstring

The message to display to the user.

fieldArray.<Object>

The list of selectable choices.

Properties
NameTypeDescription
namestring

The key name for the response.

messagestring

The key of question.

initialstring

String placeholder.

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);