Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShouldAskForEndpoint ¶
func ShouldAskForEndpoint(endpoint string, ui UserInterface, defaultValue string) bool
ShouldAskForEndpoint wraps an AskUserToConfirm dialogue only if their endpoint has changed from the default value.
func ShouldAskForToken ¶
func ShouldAskForToken(token string, ui UserInterface) bool
ShouldAskForToken wraps an AskUserToConfirm dialogue only if their token is empty or blank.
Types ¶
type InteractiveUI ¶
type InteractiveUI struct { }
InteractiveUI implements the UserInterface used by the real program, not in tests.
func (InteractiveUI) AskUserToConfirm ¶
func (InteractiveUI) AskUserToConfirm(message string) bool
AskUserToConfirm will prompt the user to confirm with the provided message.
func (InteractiveUI) ReadSecretStringFromUser ¶
func (InteractiveUI) ReadSecretStringFromUser(message string) (string, error)
ReadSecretStringFromUser can be used to read a value from the user by masking their input. It's useful for token input in our case.
func (InteractiveUI) ReadStringFromUser ¶
func (InteractiveUI) ReadStringFromUser(message string, defaultValue string) string
ReadStringFromUser can be used to read any value from the user or the defaultValue when provided.
type TestingUI ¶
TestingUI implements the UserInterface for our testing purposes.
func (TestingUI) AskUserToConfirm ¶
AskUserToConfirm works by printing the provided message to standard out and returning a Confirm dialogue up the chain.
func (TestingUI) ReadSecretStringFromUser ¶
ReadSecretStringFromUser implements the TestingUI interface for asking a user's input. It works by simply printing the message to standard output and passing the input through.
type UserInterface ¶
type UserInterface interface { ReadSecretStringFromUser(message string) (string, error) ReadStringFromUser(message string, defaultValue string) string AskUserToConfirm(message string) bool }
UserInterface is created to allow us to pass a mock user interface for testing. Since we can't properly run integration tests on code that calls PromptUI. This is because the first call to PromptUI reads from stdin correctly, but subsequent calls return EOF.