Skip to content

Commit de2f33c

Browse files
committed
refactor(cli): use cliarg.ExactNamedArg in delete command
This adds a friendly error message to the `delete` command when users do not pass an argument.
1 parent b301795 commit de2f33c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cli/delete.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ import (
55

66
"github.com/spf13/cobra"
77

8+
"github.com/coder/coder/cli/cliarg"
89
"github.com/coder/coder/cli/cliui"
910
"github.com/coder/coder/coderd/database"
1011
"github.com/coder/coder/codersdk"
1112
)
1213

14+
const DeleteError = "Did you forget to pass a workspace name? Run command with --help to see an example."
15+
1316
// nolint
1417
func delete() *cobra.Command {
1518
return &cobra.Command{
1619
Annotations: workspaceCommand,
1720
Use: "delete <workspace>",
1821
Short: "Delete a workspace",
1922
Aliases: []string{"rm"},
20-
Args: cobra.ExactArgs(1),
23+
Args: cliarg.ExactNamedArg("workspace", DeleteError),
2124
RunE: func(cmd *cobra.Command, args []string) error {
2225
client, err := createClient(cmd)
2326
if err != nil {

0 commit comments

Comments
 (0)