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

Add list and text prompts for bubble tea #4671

Merged
merged 6 commits into from
Nov 18, 2022
Merged

Conversation

bjoginapally
Copy link
Contributor

@bjoginapally bjoginapally commented Nov 16, 2022

Description

This change adds list and text prompts functionality for bubble tea. Changes in the respective commands will be made later.

Issue reference

Fixes: #3947

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Adds necessary unit tests for change
  • Adds necessary E2E tests for change
  • Unit tests passing
  • Extended the documentation / Created issue for it

Mac:

Screenshot 2022-11-16 at 12 35 12 PM

Screenshot 2022-11-16 at 12 49 00 PM

Windows:

Screenshot 2022-11-16 at 3 42 08 PM

Screenshot 2022-11-16 at 3 42 22 PM

Screenshot 2022-11-16 at 3 42 29 PM

@bjoginapally bjoginapally requested a review from a team as a code owner November 16, 2022 20:49
//go:generate mockgen -destination=./mock_bubleteaprompter.go -package=prompt -self_package github.com/project-radius/radius/pkg/cli/prompt github.com/project-radius/radius/pkg/cli/prompt BubbleTeaPrompter

// BubbleTeaPrompter contains operation to get user inputs for cli
type BubbleTeaPrompter interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need this for testing cli prompts in the commands

@bjoginapally bjoginapally changed the title Add list prompt for bubble tea Add list and text prompts for bubble tea Nov 16, 2022

// GetTextInput prompts user for a text input
func (i *BubbleTeaPrompterImpl) GetInput(program tea.Program) (string, error) {
// TODO: implement text model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text model should probably be implemented under a new folder as discussed yesterday. Is there a change on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented the text model now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then should this TODO be removed?

return "invalid model for prompt operation"
}

// Is checks for the error type is ErrUnsupportedModel.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Is checks for the error type is ErrUnsupportedModel.
// Is checks if the error provided is of type ErrUnsupportedModel.

This function actually not only checks if the given error is of type ErrUnsupportedModel, it also checks to see if the messages are equal. I was wondering if we could use another name here. Not that important though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about the name. But my thought has been to keep it consistent with other places in our code base. Let me know if you feel strongly about it and we can decide a name.

pkg/cli/prompt/list/list.go Outdated Show resolved Hide resolved
pkg/cli/prompt/list/list.go Outdated Show resolved Hide resolved
@bjoginapally bjoginapally force-pushed the bjoginapally/listprompt branch 2 times, most recently from a96a8c6 to 8706b62 Compare November 16, 2022 22:18
@anamikapan
Copy link
Contributor

Hoping the windows VM testing was done correctlyl

@bjoginapally bjoginapally force-pushed the bjoginapally/listprompt branch from 31971b7 to 320c01b Compare November 18, 2022 19:15
@bjoginapally bjoginapally merged commit 18464d8 into main Nov 18, 2022
@bjoginapally bjoginapally deleted the bjoginapally/listprompt branch November 18, 2022 19:50

package prompt

var _ error = (*ErrUnsupportedModel)(nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we ever handle this error? If this happens it's a coding mistake right?

// ------------------------------------------------------------

package list

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this based on a sample? Would be helpful to link to it if so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/charmbracelet/bubbletea/tree/master/examples/list-default here @rynowak we can update it going forward in the code as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coolio 👍

// BubbleTeaPrompter contains operation to get user inputs for cli
type BubbleTeaPrompter interface {
// GetTextInput prompts user for a text input
GetTextInput(promptMsg string) (string, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this support a default? Most of our text prompts have one.

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.

Switch CLI prompting package to bubbletea
4 participants