mirror of
https://github.com/spf13/cobra
synced 2025-04-27 09:07:19 +00:00
Avoid some unnecessary looping
This commit is contained in:
parent
34416a2637
commit
3c47a5a9c8
2 changed files with 4 additions and 6 deletions
2
cobra.go
2
cobra.go
|
@ -188,8 +188,6 @@ func ld(s, t string, ignoreCase bool) int {
|
|||
d := make([][]int, len(s)+1)
|
||||
for i := range d {
|
||||
d[i] = make([]int, len(t)+1)
|
||||
}
|
||||
for i := range d {
|
||||
d[i][0] = i
|
||||
}
|
||||
for j := range d[0] {
|
||||
|
|
|
@ -253,17 +253,17 @@ func (c *Command) enforceFlagGroupsForCompletion() {
|
|||
// If none of the flags of a one-required group are present, we make all the flags
|
||||
// of that group required so that the shell completion suggests them automatically
|
||||
for flagList, flagnameAndStatus := range oneRequiredGroupStatus {
|
||||
set := 0
|
||||
isSet := false
|
||||
|
||||
for _, isSet := range flagnameAndStatus {
|
||||
for _, isSet = range flagnameAndStatus {
|
||||
if isSet {
|
||||
set++
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// None of the flags of the group are set, mark all flags in the group
|
||||
// as required
|
||||
if set == 0 {
|
||||
if !isSet {
|
||||
for _, fName := range strings.Split(flagList, " ") {
|
||||
_ = c.MarkFlagRequired(fName)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue