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

Refactor prompt interactions in NodeHost #679

Merged
merged 4 commits into from
Aug 30, 2024
Merged

Refactor prompt interactions in NodeHost #679

merged 4 commits into from
Aug 30, 2024

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Aug 30, 2024

This pull request refactors the prompt interactions in the NodeHost class by consolidating the input, select, and confirm functions. This improves code organization and readability.

Refactor confirm method usage in commit and push sequence

  • 🚀 New interactive shell features added to runtime hosts! Now users can:

    • Select options from a list through select(message: string, options: string[]): Promise<string>
    • Enter free text input with input(message: string): Promise<string>
    • Confirm messages with confirm(message: string): Promise<boolean>
  • 🎛️ These interactive commands are now available on the NodeHost runtime in packages/cli/src/nodehost.ts, with implementation leveraging external package @inquirer/prompts.

  • 🚧 However, these methods are not yet implemented in the TestHost runtime in packages/core/src/testhost.ts, throwing "Method not implemented" errors.

  • 📚 Interfaces for ShellSelectOptions, ShellSelectChoice, ShellInputOptions, and ShellConfirmOptions have been added to packages/core/src/types/prompt_template.d.ts, which defines the public API.

  • 🎬 Not only runtime hosts, these interactive features are expected in the PromptContext as well in packages/core/src/promptcontext.ts.

  • 💼 Three new utility functions in packages/cli/src/input.ts have been added to handle these interactive operations. Features are:

    • shellSelect - lets a user select between multiple options
    • shellInput - lets a user input text
    • shellConfirm - lets a user confirm a message.

Overall, these changes enhance interactivity and provide a more interactive CLI experience for users! 🎉👏

generated by pr-describe

Copy link

The changes in the GIT_DIFF involve implementing new user input functionalities in the system. These include:

  • User selection from a list of options using shellSelect
  • Text input from the user using shellInput
  • Yes/No confirmation from the user using shellConfirm

These changes are implemented in a new TypeScript file input.ts and are then imported and used in nodehost.ts. The RuntimeHost interface in host.ts is also updated to include these new methods. It seems like a comprehensive update and test cases for these new functionalities are also included.

However, the test cases in testhost.ts simply throw a "Method not implemented." error for now. This could be improved in the future by adding actual test cases.

Other than that, LGTM 🚀

generated by pr-review

@pelikhan pelikhan merged commit 7c39bb1 into main Aug 30, 2024
10 checks passed
@pelikhan pelikhan deleted the cli-input branch August 30, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant