Skip to content

Commit 57a8f67

Browse files
Merge pull request #725 from moznion/rename4delpswd
Revise the phrasing of `password delete` subcmd usage to place greater emphasis on the intention of receiving a password ID
2 parents dc6b9fc + 1f75a20 commit 57a8f67

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Diff for: internal/cmd/password/delete.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ func DeleteCmd(ch *cmdutil.Helper) *cobra.Command {
1919
var force bool
2020

2121
cmd := &cobra.Command{
22-
Use: "delete <database> <branch> <password>",
22+
Use: "delete <database> <branch> <password-id>",
2323
Short: "Delete a branch password",
24-
Args: cmdutil.RequiredArgs("database", "branch", "password"),
24+
Args: cmdutil.RequiredArgs("database", "branch", "password-id"),
2525
Aliases: []string{"rm"},
2626
RunE: func(cmd *cobra.Command, args []string) error {
2727
ctx := cmd.Context()
2828
database := args[0]
2929
branch := args[1]
30-
password := args[2]
30+
passwordId := args[2]
3131

3232
client, err := ch.Client()
3333
if err != nil {
@@ -39,7 +39,7 @@ func DeleteCmd(ch *cmdutil.Helper) *cobra.Command {
3939
return fmt.Errorf("cannot delete password with the output format %q (run with -force to override)", ch.Printer.Format())
4040
}
4141

42-
confirmationName := fmt.Sprintf("%s/%s/%s", database, branch, password)
42+
confirmationName := fmt.Sprintf("%s/%s/%s", database, branch, passwordId)
4343
if !printer.IsTTY {
4444
return fmt.Errorf("cannot confirm deletion of password %q (run with -force to override)", confirmationName)
4545
}
@@ -67,20 +67,20 @@ func DeleteCmd(ch *cmdutil.Helper) *cobra.Command {
6767
}
6868

6969
end := ch.Printer.PrintProgress(fmt.Sprintf("Deleting password %s from %s/%s",
70-
printer.BoldBlue(password), printer.BoldBlue(database), printer.BoldBlue(branch)))
70+
printer.BoldBlue(passwordId), printer.BoldBlue(database), printer.BoldBlue(branch)))
7171
defer end()
7272

7373
err = client.Passwords.Delete(ctx, &ps.DeleteDatabaseBranchPasswordRequest{
7474
Organization: ch.Config.Organization,
7575
Database: database,
7676
Branch: branch,
77-
PasswordId: password,
77+
PasswordId: passwordId,
7878
})
7979
if err != nil {
8080
switch cmdutil.ErrCode(err) {
8181
case ps.ErrNotFound:
8282
return fmt.Errorf("password %s does not exist in branch %s of %s (organization: %s)",
83-
printer.BoldBlue(password), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization))
83+
printer.BoldBlue(passwordId), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization))
8484
default:
8585
return cmdutil.HandleError(err)
8686
}
@@ -90,15 +90,15 @@ func DeleteCmd(ch *cmdutil.Helper) *cobra.Command {
9090

9191
if ch.Printer.Format() == printer.Human {
9292
ch.Printer.Printf("Password %s was successfully deleted from %s.\n",
93-
printer.BoldBlue(password), printer.BoldBlue(branch))
93+
printer.BoldBlue(passwordId), printer.BoldBlue(branch))
9494
return nil
9595
}
9696

9797
return ch.Printer.PrintResource(
9898
map[string]string{
99-
"result": "password deleted",
100-
"password": password,
101-
"branch": branch,
99+
"result": "password deleted",
100+
"password_id": passwordId,
101+
"branch": branch,
102102
},
103103
)
104104
},

Diff for: internal/cmd/password/delete_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func TestPassword_DeleteCmd(t *testing.T) {
5858
c.Assert(svc.DeleteFnInvoked, qt.IsTrue)
5959

6060
res := map[string]string{
61-
"result": "password deleted",
62-
"password": password,
63-
"branch": branch,
61+
"result": "password deleted",
62+
"password_id": password,
63+
"branch": branch,
6464
}
6565
c.Assert(buf.String(), qt.JSONEquals, res)
6666
}

0 commit comments

Comments
 (0)