diff --git a/cmd/delete.go b/cmd/delete.go index 44d0bd65..2e7f7bbf 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -9,9 +9,7 @@ import ( func init() { root.AddCommand(deleteCmd) - deleteCmd.Flags().StringP("name", "n", "", "optionally specify an explicit name to remove, overriding path-derivation. $FAAS_NAME") - viper.BindPFlag("name", deleteCmd.Flags().Lookup("name")) } var deleteCmd = &cobra.Command{ @@ -20,6 +18,9 @@ var deleteCmd = &cobra.Command{ Long: `Removes the deployed Service Function for the current directory, but does not delete anything locally. If no code updates have been made beyond the defaults, this would bring the current codebase back to a state equivalent to having run "create --local".`, SuggestFor: []string{"remove", "rm"}, RunE: delete, + PreRun: func(cmd *cobra.Command, args []string) { + viper.BindPFlag("name", cmd.Flags().Lookup("name")) + }, } func delete(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/describe.go b/cmd/describe.go index fae6736e..fd76ad04 100644 --- a/cmd/describe.go +++ b/cmd/describe.go @@ -18,10 +18,8 @@ func init() { root.AddCommand(describeCmd) describeCmd.Flags().StringP("output", "o", "yaml", "optionally specify output format (yaml,xml,json).") - viper.BindPFlag("output", describeCmd.Flags().Lookup("output")) describeCmd.Flags().StringP("name", "n", "", "optionally specify an explicit name for the serive, overriding path-derivation. $FAAS_NAME") - viper.BindPFlag("name", describeCmd.Flags().Lookup("name")) } var describeCmd = &cobra.Command{ @@ -30,6 +28,10 @@ var describeCmd = &cobra.Command{ Long: `Describe Service Function`, SuggestFor: []string{"desc"}, RunE: describe, + PreRun: func(cmd *cobra.Command, args []string) { + viper.BindPFlag("output", cmd.Flags().Lookup("output")) + viper.BindPFlag("name", cmd.Flags().Lookup("name")) + }, } func describe(cmd *cobra.Command, args []string) (err error) {