mirror of https://github.com/knative/func.git
bind flags on pre-run rather than init
This commit is contained in:
parent
032ab96787
commit
625a270942
|
@ -9,9 +9,7 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
root.AddCommand(deleteCmd)
|
root.AddCommand(deleteCmd)
|
||||||
|
|
||||||
deleteCmd.Flags().StringP("name", "n", "", "optionally specify an explicit name to remove, overriding path-derivation. $FAAS_NAME")
|
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{
|
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".`,
|
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"},
|
SuggestFor: []string{"remove", "rm"},
|
||||||
RunE: delete,
|
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) {
|
func delete(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
|
|
@ -18,10 +18,8 @@ func init() {
|
||||||
root.AddCommand(describeCmd)
|
root.AddCommand(describeCmd)
|
||||||
|
|
||||||
describeCmd.Flags().StringP("output", "o", "yaml", "optionally specify output format (yaml,xml,json).")
|
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")
|
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{
|
var describeCmd = &cobra.Command{
|
||||||
|
@ -30,6 +28,10 @@ var describeCmd = &cobra.Command{
|
||||||
Long: `Describe Service Function`,
|
Long: `Describe Service Function`,
|
||||||
SuggestFor: []string{"desc"},
|
SuggestFor: []string{"desc"},
|
||||||
RunE: describe,
|
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) {
|
func describe(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
|
Loading…
Reference in New Issue