(buf io.StringWriter, cmd *Command)
| 549 | } |
| 550 | |
| 551 | func writeFlags(buf io.StringWriter, cmd *Command) { |
| 552 | prepareCustomAnnotationsForFlags(cmd) |
| 553 | WriteStringAndCheck(buf, ` flags=() |
| 554 | two_word_flags=() |
| 555 | local_nonpersistent_flags=() |
| 556 | flags_with_completion=() |
| 557 | flags_completion=() |
| 558 | |
| 559 | `) |
| 560 | |
| 561 | if cmd.DisableFlagParsing { |
| 562 | WriteStringAndCheck(buf, " flag_parsing_disabled=1\n") |
| 563 | } |
| 564 | |
| 565 | localNonPersistentFlags := cmd.LocalNonPersistentFlags() |
| 566 | cmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) { |
| 567 | if nonCompletableFlag(flag) { |
| 568 | return |
| 569 | } |
| 570 | writeFlag(buf, flag, cmd) |
| 571 | if len(flag.Shorthand) > 0 { |
| 572 | writeShortFlag(buf, flag, cmd) |
| 573 | } |
| 574 | // localNonPersistentFlags are used to stop the completion of subcommands when one is set |
| 575 | // if TraverseChildren is true we should allow to complete subcommands |
| 576 | if localNonPersistentFlags.Lookup(flag.Name) != nil && !cmd.Root().TraverseChildren { |
| 577 | writeLocalNonPersistentFlag(buf, flag) |
| 578 | } |
| 579 | }) |
| 580 | cmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) { |
| 581 | if nonCompletableFlag(flag) { |
| 582 | return |
| 583 | } |
| 584 | writeFlag(buf, flag, cmd) |
| 585 | if len(flag.Shorthand) > 0 { |
| 586 | writeShortFlag(buf, flag, cmd) |
| 587 | } |
| 588 | }) |
| 589 | |
| 590 | WriteStringAndCheck(buf, "\n") |
| 591 | } |
| 592 | |
| 593 | func writeRequiredFlag(buf io.StringWriter, cmd *Command) { |
| 594 | WriteStringAndCheck(buf, " must_have_one_flag=()\n") |
no test coverage detected