Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance consola.prompt Select Options to Support Generic Values Matching Clack's Flexibility #282

Open
1 task
shtse8 opened this issue Mar 16, 2024 · 0 comments
Labels
enhancement New feature or request propmpts

Comments

@shtse8
Copy link

shtse8 commented Mar 16, 2024

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 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?
@pi0 pi0 added enhancement New feature or request propmpts labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request propmpts
Projects
None yet
Development

No branches or pull requests

2 participants