feat: Add confirm prompts to some cli actions (#1591)

* feat: Add confirm prompts to some cli actions
- Add optional -y skip. Standardize -y flag across commands
This commit is contained in:
Steven Masley
2022-05-20 10:59:04 -05:00
committed by GitHub
parent 4f70f84635
commit ad946c3902
10 changed files with 121 additions and 39 deletions

View File

@ -10,12 +10,20 @@ import (
)
func stop() *cobra.Command {
return &cobra.Command{
cmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "stop <workspace>",
Short: "Build a workspace with the stop state",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Confirm stop workspace?",
IsConfirm: true,
})
if err != nil {
return err
}
client, err := createClient(cmd)
if err != nil {
return err
@ -38,4 +46,6 @@ func stop() *cobra.Command {
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
},
}
cliui.AllowSkipPrompt(cmd)
return cmd
}