Description
I've been utilizing Consola for logging and interacting with the console in my projects. Recently, I came across a scenario where I needed to use consola.prompt for a selection input. I noticed that Consola, which uses Clack for powering consola.prompt, restricts select options values to strings. However, Clack itself supports generic values for these options, offering enhanced flexibility and utility by allowing the return of objects or other types beyond just strings.
Issue
The limitation to string values in select options within Consola's prompt functionality leads to additional parsing and handling when developers might need to associate selected options with complex objects or other non-string values. This constraint diverges from Clack's inherent flexibility and reduces the effectiveness of consola.prompt in scenarios where complex, associated data needs to be returned directly from a selection.
Proposed Enhancement
I propose that Consola's implementation of consola.prompt for select options be enhanced to support generic values, aligning with Clack's capabilities. This change would allow developers to directly associate objects or other types with select options, significantly improving usability and reducing the need for workarounds or additional parsing logic.
Benefits
Aligns Consola's functionality more closely with Clack's capabilities, maintaining consistency.
Reduces the need for additional parsing or mapping logic when dealing with complex data associated with select options.
Enhances the developer experience by providing a more flexible and powerful tool for console interactions.
Example Scenario
Consider a command-line application where a user selects from a list of configurations, each represented as an object with multiple properties. Under the current string-only constraint, developers must map selected strings back to the corresponding configuration objects. Allowing generic values directly as select options would streamline this process, enabling a more intuitive and efficient workflow.
I believe this enhancement would significantly benefit the Consola user community by providing a more flexible and powerful tool for interactive console applications. Thank you for considering this proposal.
Additional information
[ ] Would you be willing to help implement this feature?
Describe the feature
Description I've been utilizing Consola for logging and interacting with the console in my projects. Recently, I came across a scenario where I needed to use
consola.prompt
for a selection input. I noticed that Consola, which uses Clack for poweringconsola.prompt
, restricts select options values to strings. However, Clack itself supports generic values for these options, offering enhanced flexibility and utility by allowing the return of objects or other types beyond just strings.Issue The limitation to string values in select options within Consola's prompt functionality leads to additional parsing and handling when developers might need to associate selected options with complex objects or other non-string values. This constraint diverges from Clack's inherent flexibility and reduces the effectiveness of
consola.prompt
in scenarios where complex, associated data needs to be returned directly from a selection.Proposed Enhancement I propose that Consola's implementation of
consola.prompt
for select options be enhanced to support generic values, aligning with Clack's capabilities. This change would allow developers to directly associate objects or other types with select options, significantly improving usability and reducing the need for workarounds or additional parsing logic.Benefits
Example Scenario Consider a command-line application where a user selects from a list of configurations, each represented as an object with multiple properties. Under the current string-only constraint, developers must map selected strings back to the corresponding configuration objects. Allowing generic values directly as select options would streamline this process, enabling a more intuitive and efficient workflow.
I believe this enhancement would significantly benefit the Consola user community by providing a more flexible and powerful tool for interactive console applications. Thank you for considering this proposal.
Additional information