Skip to content

Commit

Permalink
Merge pull request #60 from pusher/delete-function-config
Browse files Browse the repository at this point in the history
Delete function config with argument not option
  • Loading branch information
willpusher authored Jun 5, 2023
2 parents d741a9a + 357556a commit 30d5df4
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions commands/channels/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,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 @@ -176,11 +171,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 30d5df4

Please sign in to comment.