Skip to content

feat: Add success messages for CLI commands #2634

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

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cli/delete.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"fmt"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,7 +42,14 @@ func delete() *cobra.Command {
if err != nil {
return err
}
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)

err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
if err != nil {
return err
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been deleted!\n", cliui.Styles.Keyword.Render(workspace.Name))
return nil
},
}
cliui.AllowSkipPrompt(cmd)
Expand Down
2 changes: 2 additions & 0 deletions cli/resetpassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"database/sql"
"fmt"

"github.com/spf13/cobra"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -80,6 +81,7 @@ func resetPassword() *cobra.Command {
return xerrors.Errorf("updating password: %w", err)
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nPassword has been reset for user %s!\n", cliui.Styles.Keyword.Render(user.Username))
return nil
},
}
Expand Down
10 changes: 9 additions & 1 deletion cli/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"fmt"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -39,7 +40,14 @@ func start() *cobra.Command {
if err != nil {
return err
}
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)

err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
if err != nil {
return err
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been started!\n", cliui.Styles.Keyword.Render(workspace.Name))
return nil
},
}
cliui.AllowSkipPrompt(cmd)
Expand Down
10 changes: 9 additions & 1 deletion cli/stop.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"fmt"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -39,7 +40,14 @@ func stop() *cobra.Command {
if err != nil {
return err
}
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)

err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
if err != nil {
return err
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been stopped!\n", cliui.Styles.Keyword.Render(workspace.Name))
return nil
},
}
cliui.AllowSkipPrompt(cmd)
Expand Down
5 changes: 5 additions & 0 deletions cli/userstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ import (
// createUserStatusCommand sets a user status.
func createUserStatusCommand(sdkStatus codersdk.UserStatus) *cobra.Command {
var verb string
var pastVerb string
var aliases []string
var short string
switch sdkStatus {
case codersdk.UserStatusActive:
verb = "activate"
pastVerb = "activated"
aliases = []string{"active"}
short = "Update a user's status to 'active'. Active users can fully interact with the platform"
case codersdk.UserStatusSuspended:
verb = "suspend"
pastVerb = "suspended"
aliases = []string{"rm", "delete"}
short = "Update a user's status to 'suspended'. A suspended user cannot log into the platform"
default:
Expand Down Expand Up @@ -76,6 +79,8 @@ func createUserStatusCommand(sdkStatus codersdk.UserStatus) *cobra.Command {
if err != nil {
return xerrors.Errorf("%s user: %w", verb, err)
}

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nUser %s has been %s!\n", cliui.Styles.Keyword.Render(user.Username), pastVerb)
return nil
},
}
Expand Down