Skip to content

Commit

Permalink
command aliases (#1578)
Browse files Browse the repository at this point in the history
Ensures commands which have subcommands to operate on individual members
(list, add, remove etc) have singular and plural as aliases.

Ensures consistent usage of linux-command-style aliases for list,remove
and rename operations: "ls", "rm", "mv"
  • Loading branch information
lkingland committed Feb 23, 2023
1 parent 91c95a7 commit 3624ccb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cmd/config_envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func NewConfigEnvsCmd(loadSaver functionLoaderSaver) *cobra.Command {
Prints configured Environment variable for a function project present in
the current directory or from the directory specified with --path.
`,
SuggestFor: []string{"ensv", "env"},
Aliases: []string{"env"},
SuggestFor: []string{"ensv"},
PreRunE: bindEnv("path", "output"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loadSaver)
Expand Down Expand Up @@ -138,7 +139,8 @@ func NewConfigEnvsRemoveCmd() *cobra.Command {
Interactive prompt to remove Environment variables from the function project
in the current directory or from the directory specified with --path.
`,
SuggestFor: []string{"rm", "del", "delete", "rmeove"},
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
Expand Down
4 changes: 3 additions & 1 deletion cmd/config_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func NewConfigLabelsCmd(loaderSaver functionLoaderSaver) *cobra.Command {
Prints configured labels for a function project present in
the current directory or from the directory specified with --path.
`,
SuggestFor: []string{"albels", "abels", "label"},
Aliases: []string{"label"},
SuggestFor: []string{"albels", "abels"},
PreRunE: bindEnv("path"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loaderSaver)
Expand Down Expand Up @@ -66,6 +67,7 @@ the local machine.
Interactive prompt to remove labels from the function project in the current
directory or from the directory specified with --path.
`,
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/config_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func NewConfigVolumesCmd() *cobra.Command {
Prints configured Volume mounts for a function project present in
the current directory or from the directory specified with --path.
`,
SuggestFor: []string{"volums", "volume", "vols"},
Aliases: []string{"volume"},
SuggestFor: []string{"vol", "volums", "vols"},
PreRunE: bindEnv("path"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
Expand Down Expand Up @@ -81,6 +82,7 @@ func NewConfigVolumesRemoveCmd() *cobra.Command {
Interactive prompt to remove Volume mounts from the function project
in the current directory or from the directory specified with --path.
`,
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
6 changes: 4 additions & 2 deletions cmd/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ EXAMPLES

func NewRepositoryListCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Short: "List repositories",
Use: "list",
Short: "List repositories",
Use: "list",
Aliases: []string{"ls"},
}

cmd.RunE = func(_ *cobra.Command, args []string) error {
Expand Down Expand Up @@ -209,6 +210,7 @@ func NewRepositoryRenameCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Short: "Rename a repository",
Use: "rename <old> <new>",
Aliases: []string{"mv"},
PreRunE: bindEnv("confirm"),
}

Expand Down

0 comments on commit 3624ccb

Please sign in to comment.