Creates an OptionGetter function to dynamically retrieve the value of a command option. The getter function accepts an optional OptionGetterOptions object, which can be used to prompt the user when no value is provided and/or validate the value.
OptionGetter
OptionGetterOptions
The options to create the getter.
The getter function for the provided option.
const fooGetter = createOptionGetter({ name: 'foo', option: { type: 'string', default: 'default foo', }, value: 'foo value', client: new Client(),});const val = fooGetter({ prompt: { message: 'Enter foo' } }); // 'foo value' Copy
const fooGetter = createOptionGetter({ name: 'foo', option: { type: 'string', default: 'default foo', }, value: 'foo value', client: new Client(),});const val = fooGetter({ prompt: { message: 'Enter foo' } }); // 'foo value'
Throws an error if the option is required and no value is provided or the value is invalid.
Creates an
OptionGetter
function to dynamically retrieve the value of a command option. The getter function accepts an optionalOptionGetterOptions
object, which can be used to prompt the user when no value is provided and/or validate the value.