(buf io.StringWriter, cmd *Command)
| 591 | } |
| 592 | |
| 593 | func writeRequiredFlag(buf io.StringWriter, cmd *Command) { |
| 594 | WriteStringAndCheck(buf, " must_have_one_flag=()\n") |
| 595 | flags := cmd.NonInheritedFlags() |
| 596 | flags.VisitAll(func(flag *pflag.Flag) { |
| 597 | if nonCompletableFlag(flag) { |
| 598 | return |
| 599 | } |
| 600 | if _, ok := flag.Annotations[BashCompOneRequiredFlag]; ok { |
| 601 | format := " must_have_one_flag+=(\"--%s" |
| 602 | if flag.Value.Type() != "bool" { |
| 603 | format += "=" |
| 604 | } |
| 605 | format += cbn |
| 606 | WriteStringAndCheck(buf, fmt.Sprintf(format, flag.Name)) |
| 607 | |
| 608 | if len(flag.Shorthand) > 0 { |
| 609 | WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_flag+=(\"-%s"+cbn, flag.Shorthand)) |
| 610 | } |
| 611 | } |
| 612 | }) |
| 613 | } |
| 614 | |
| 615 | func writeRequiredNouns(buf io.StringWriter, cmd *Command) { |
| 616 | WriteStringAndCheck(buf, " must_have_one_noun=()\n") |
no test coverage detected