Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 22, 2023
1 parent 2f52613 commit 79d7f18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions internal/pflagfork/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ func (f Flag) IsRepeatable() bool {
return false
}

func (f Flag) Split(arg string) (prefix, optarg string) {
func (f Flag) Split(arg string) []string {
delimiter := string(f.OptargDelimiter())
splitted := strings.SplitN(arg, delimiter, 2)
return splitted[0] + delimiter, splitted[1]
return strings.SplitAfterN(arg, delimiter, 2)
}

func (f Flag) Matches(arg string, posix bool) bool {
Expand Down
4 changes: 2 additions & 2 deletions traverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ loop:

if inFlag.Flag == nil {
LOG.Printf("flag %#v is unknown", arg)
} else if splitted := strings.SplitN(arg, string(inFlag.OptargDelimiter()), 2); len(splitted) > 1 {
} else if splitted := inFlag.Flag.Split(arg); len(splitted) > 1 {
inFlag.Args = append(inFlag.Args, splitted[1])
}
continue
Expand Down Expand Up @@ -164,7 +164,7 @@ loop:
case !c.DisableFlagParsing && strings.HasPrefix(context.Value, "-") && (fs.IsInterspersed() || len(inPositionals) == 0):
if f := fs.LookupArg(context.Value); f != nil && strings.Contains(context.Value, string(f.OptargDelimiter())) {
LOG.Printf("completing optional flag argument for arg %#v\n", context.Value)
prefix, _ := f.Split(context.Value)
prefix := f.Split(context.Value)[0]

switch f.Value.Type() {
case "bool":
Expand Down

0 comments on commit 79d7f18

Please sign in to comment.