selectWith adds a `with(args...)` selection to the query builder if any constructor flags were set.
(cmd *cobra.Command)
| 547 | // selectWith adds a `with(args...)` selection to the query builder if any |
| 548 | // constructor flags were set. |
| 549 | func (fc *FuncCommand) selectWith(cmd *cobra.Command) error { |
| 550 | if fc.withFn == nil { |
| 551 | return nil |
| 552 | } |
| 553 | // Check if any with-args flags were changed. |
| 554 | anyChanged := false |
| 555 | for _, a := range fc.withFn.SupportedArgs() { |
| 556 | flag, err := a.GetFlag(cmd.Flags()) |
| 557 | if err != nil { |
| 558 | continue |
| 559 | } |
| 560 | if flag.Changed { |
| 561 | anyChanged = true |
| 562 | break |
| 563 | } |
| 564 | } |
| 565 | if !anyChanged { |
| 566 | return nil |
| 567 | } |
| 568 | return fc.selectFunc(fc.withFn, cmd) |
| 569 | } |
| 570 | |
| 571 | // addFlagsForFunction creates the flags for a function's arguments. |
| 572 | func (fc *FuncCommand) addFlagsForFunction(cmd *cobra.Command, fn *modFunction) error { |
no test coverage detected