change args to use flags instead, so that values starting with hyphen can be correctly parsed.

This commit is contained in:
Jijie Wei
2020-05-26 17:22:04 -07:00
parent 144471ce78
commit 572260c0f0
5 changed files with 335 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/go-errors/errors"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
// parseFieldPath parse a flag value into a field path
@@ -39,6 +40,16 @@ func parseFieldPath(path string) ([]string, error) {
return newParts, nil
}
func isFlagSet(name string, c *cobra.Command) bool {
set := false
c.Flags().Visit(func(f *flag.Flag) {
if f.Name == name {
set = true
}
})
return set
}
func handleError(c *cobra.Command, err error) error {
if err == nil {
return nil