Skip to content

Commit

Permalink
feat(cmd): add aliases for database user management
Browse files Browse the repository at this point in the history
Fixes #1030
  • Loading branch information
curzolapierre committed Jan 24, 2024
1 parent 6845dcf commit 7c1903c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### To be Released

* feat(addons): add aliases for database user management (i.e. using format: `database-users-<action>`)

### 1.30.0

* feat(addons): add user management commands ([PR#1019](https://github.com/Scalingo/cli/pull/1019))
Expand Down
21 changes: 12 additions & 9 deletions cmd/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ var (
}

databaseListUsers = cli.Command{
Name: "database-list-users",
Name: "database-users-list",
Aliases: []string{"database-list-users"},
Category: "Addons",
Usage: "Print database's users",
Flags: []cli.Flag{&appFlag, &addonFlag},
Expand All @@ -150,7 +151,7 @@ var (
Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
Examples: []string{
"scalingo --app myapp --addon addon-uuid database-list-users",
"scalingo --app myapp --addon addon-uuid database-users-list",
},
}.Render(),

Expand All @@ -168,7 +169,8 @@ Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
}

databaseDeleteUser = cli.Command{
Name: "database-delete-user",
Name: "database-users-delete",
Aliases: []string{"database-delete-user"},
Category: "Addons",
ArgsUsage: "user",
Usage: "Delete a database's user",
Expand All @@ -178,13 +180,13 @@ Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
Examples: []string{
"scalingo --app myapp --addon addon-uuid database-delete-user my_user",
"scalingo --app myapp --addon addon-uuid database-users-delete my_user",
},
}.Render(),

Action: func(c *cli.Context) error {
if c.Args().Len() != 1 {
return cli.ShowCommandHelp(c, "database-delete-user")
return cli.ShowCommandHelp(c, "database-users-delete")
}

currentApp := detect.CurrentApp(c)
Expand All @@ -202,7 +204,8 @@ Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
}

databaseCreateUser = cli.Command{
Name: "database-create-user",
Name: "database-users-create",
Aliases: []string{"database-create-user"},
Category: "Addons",
ArgsUsage: "user",
Usage: "Create new database user",
Expand All @@ -216,14 +219,14 @@ Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
Only available on ` + fmt.Sprintf("%s", dbUsers.SupportedAddons),
Examples: []string{
"scalingo --app myapp --addon addon-uuid database-create-user my_user",
"scalingo --app myapp --addon addon-uuid database-create-user --read-only my_user",
"scalingo --app myapp --addon addon-uuid database-users-create my_user",
"scalingo --app myapp --addon addon-uuid database-users-create --read-only my_user",
},
}.Render(),

Action: func(c *cli.Context) error {
if c.NArg() != 1 {
return cli.ShowCommandHelp(c, "database-create-user")
return cli.ShowCommandHelp(c, "database-users-create")
}

currentApp := detect.CurrentApp(c)
Expand Down

0 comments on commit 7c1903c

Please sign in to comment.