Skip to content

Commit

Permalink
Delete function config with argument not option
Browse files Browse the repository at this point in the history
  • Loading branch information
willpusher committed Jun 5, 2023
1 parent 9298bf0 commit 357556a
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions commands/channels/functions.go
Expand Up @@ -130,27 +130,22 @@ func NewConfigUpdateCommand(functionService api.FunctionService) (*cobra.Command
return cmd, nil
}

func NewConfigDeleteCommand(functionService api.FunctionService) (*cobra.Command, error) {
func NewConfigDeleteCommand(functionService api.FunctionService) *cobra.Command {
cmd := &cobra.Command{
Use: "delete",
Short: "Delete a function config from a Channels app",
Args: cobra.NoArgs,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
err := functionService.DeleteFunctionConfig(commands.AppID, commands.FunctionConfigName)
err := functionService.DeleteFunctionConfig(commands.AppID, args[0])
if err != nil {
return err
}

fmt.Fprintf(cmd.OutOrStdout(), "deleted function config %s\n", commands.FunctionConfigName)
fmt.Fprintf(cmd.OutOrStdout(), "deleted function config %s\n", args[0])
return nil
},
}
cmd.PersistentFlags().StringVar(&commands.FunctionConfigName, "name", "", "Function config name. Can only contain A-Za-z0-9-_")
err := cmd.MarkPersistentFlagRequired("name")
if err != nil {
return nil, err
}
return cmd, nil
return cmd
}

func NewConfigCommand(pusher api.FunctionService) (*cobra.Command, error) {
Expand All @@ -170,11 +165,7 @@ func NewConfigCommand(pusher api.FunctionService) (*cobra.Command, error) {
return nil, err
}
cmd.AddCommand(c)
c, err = NewConfigDeleteCommand(pusher)
if err != nil {
return nil, err
}
cmd.AddCommand(c)
cmd.AddCommand(NewConfigDeleteCommand(pusher))
return cmd, nil
}

Expand Down

0 comments on commit 357556a

Please sign in to comment.