Update kube to support new pflag/cobra
This commit is contained in:
@@ -16,11 +16,23 @@ limitations under the License.
|
||||
|
||||
package util
|
||||
|
||||
import "strings"
|
||||
|
||||
import "github.com/spf13/pflag"
|
||||
|
||||
func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
from := []string{"-", "_"}
|
||||
to := "."
|
||||
for _, sep := range from {
|
||||
name = strings.Replace(name, sep, to, -1)
|
||||
}
|
||||
// Type convert to indicate normalization has been done.
|
||||
return pflag.NormalizedName(name)
|
||||
}
|
||||
|
||||
// InitFlags normalizes and parses the command line flags
|
||||
func InitFlags() {
|
||||
pflag.CommandLine.SetWordSeparators([]string{"-", "_"})
|
||||
pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc)
|
||||
AddAllFlagsToPFlags()
|
||||
pflag.Parse()
|
||||
}
|
||||
|
Reference in New Issue
Block a user