Skip to content

Commit c365495

Browse files
committed
fixup
1 parent 3fcf037 commit c365495

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

command.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,19 +591,20 @@ func (inv *Invocation) with(fn func(*Invocation)) *Invocation {
591591
func (inv *Invocation) complete() []string {
592592
prev, cur := inv.CurWords()
593593

594+
// If the current word is a flag
594595
if strings.HasPrefix(cur, "--") {
595-
// If the current word is a flag set using `=`, use it's handler
596-
if strings.Contains(cur, "=") {
597-
words := strings.Split(cur, "=")
598-
flagName := words[0][2:]
596+
flagParts := strings.Split(cur, "=")
597+
flagName := flagParts[0][2:]
598+
// If it's an equals flag
599+
if len(flagParts) == 2 {
599600
if out := inv.completeFlag(flagName); out != nil {
600601
for i, o := range out {
601602
out[i] = fmt.Sprintf("--%s=%s", flagName, o)
602603
}
603604
return out
604605
}
605-
} else if out := inv.Command.Options.ByFlag(cur[2:]); out != nil {
606-
// If the current word is a complete flag, auto-complete it so the
606+
} else if out := inv.Command.Options.ByFlag(flagName); out != nil {
607+
// If the current word is a valid flag, auto-complete it so the
607608
// shell moves the cursor
608609
return []string{cur}
609610
}

0 commit comments

Comments
 (0)