Documentation
¶
Overview ¶
Package prompts is a collection of functions for requesting information from the user such as their username, email, or whether or not they want to perform an action.
This package relies on the errs, validate, prefs, and ui packages to properly handle when to ask for input from the user depending on whether the client is attached to a terminal or not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWarning = "The actions you are about to perform cannot be undone."
DefaultWarning represents the default warning to be used with a ConfirmDialog
var SelectedAdd = promptui.SelectedAdd
SelectedAdd is returned when a user has requested to create the given value
Functions ¶
func Confirm ¶
Confirm prompts the user to perform an action, accepting optional labels and a preamble warning.
If no warning is provided, a warning will not be displayed. If no label is provided, a default label will be used.
A confirm prompt should be defaultYes if the user has asked for this explicit action (e.g. we want to destroy a machine). If this prompt is due to a possible side effect (e.g. changing a password while updating a profie) then defaultYes should be false.
Similar to defaultYes, defaultValue should be true in situations where the user is explicitly asking to do something. This way, when we're not attached to a terminal we won't ask the user to confirm they want to perform the action, we'll just do it. In these situations where scripting is expected, defaultValue can be set by the value of a `--yes` flag.
func Password ¶
Password prompts the user to provide a password. The value provided by the user is masked.
If confirm is true the user will be prompted to supply the password again.
func SelectAcceptAction ¶
SelectAcceptAction prompts the user to select whether they want to log into an existing account or to create a new one when they're accepting an org invitation.
Types ¶
type SelectCreatePrompt ¶
SelectCreatePrompt represents a function that prompts the user witha list of choices they can select or the ability to create a new item. If they choose to create a new item they are prompted with a string prompt. The index returned will be SelectedAdd.
A user can provide a default choice, if it exists then the index and displayed name of the item are returned. The success state of the prompt is displayed.
var SelectCreateOrg SelectCreatePrompt
SelectCreateOrg prompts the user to select or create an org
var SelectCreateProject SelectCreatePrompt
SelectCreateProject prompts the user to select or create a new project.
var SelectCreateRole SelectCreatePrompt
SelectCreateRole prompts the user to select or create a new role.
var SelectCreateTeam SelectCreatePrompt
SelectCreateTeam prompts the user to select or create a new team.
type SelectPrompt ¶
SelectPrompt represents a function that prompts the user with a list of choices they can select. If the choice exists then the index and displayed name of the item are returned and the prompt is not displayed.
var SelectOrg SelectPrompt
SelectOrg prompts the user to select an org.
var SelectProject SelectPrompt
SelectProject prompts the user to select a project.
var SelectRole SelectPrompt
SelectRole prompts the user to select a role.
var SelectTeam SelectPrompt
SelectTeam prompts the user to select a team.
type StringPrompt ¶
StringPrompt represents a function that prompts the user and returns a string. It supports accepting a string as a default value and a boolean representing whether it should automatically validate the data.
When the client is not attached to a terminal the prompt will validate the defaultValue returning an error of the default value. If no value is provided then an error is returned.
var Email StringPrompt
Email asks the user to provide an email address
var EnvName StringPrompt
EnvName asks the user to provide a name for an environment
var FullName StringPrompt
FullName asks the user to provide a full name
var InviteCode StringPrompt
InviteCode ask the user to provide an org invite code
var MachineName StringPrompt
MachineName asks the user to provide a name for a machine
var OrgName StringPrompt
OrgName asks the user to provide a name for an org
var ProjectName StringPrompt
ProjectName asks the user to provide a name for a project
var RoleName StringPrompt
RoleName asks the user to provide a name for a role (team)
var ServiceName StringPrompt
ServiceName asks the user to provide a name for a service
var TeamName StringPrompt
TeamName asks the user to provide a name for a team
var Username StringPrompt
Username asks the user to provide a username
var VerificationCode StringPrompt
VerificationCode asks the user to provide a verification code