Yield the lines for the flag part of the help.
(self)
| 554 | print("\n".join(self.emit_flag_help())) |
| 555 | |
| 556 | def emit_flag_help(self) -> t.Generator[str, None, None]: |
| 557 | """Yield the lines for the flag part of the help.""" |
| 558 | if not self.flags: |
| 559 | return |
| 560 | |
| 561 | for flags, (cfg, fhelp) in self.flags.items(): |
| 562 | try: |
| 563 | if not isinstance(flags, tuple): # type:ignore[unreachable] |
| 564 | flags = (flags,) # type:ignore[assignment] |
| 565 | flags = sorted(flags, key=len) # type:ignore[assignment] |
| 566 | flags = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in flags) |
| 567 | yield flags |
| 568 | yield indent(dedent(fhelp.strip())) |
| 569 | cfg_list = " ".join( |
| 570 | f"--{clname}.{prop}={val}" |
| 571 | for clname, props_dict in cfg.items() |
| 572 | for prop, val in props_dict.items() |
| 573 | ) |
| 574 | cfg_txt = "Equivalent to: [%s]" % cfg_list |
| 575 | yield indent(dedent(cfg_txt)) |
| 576 | except Exception as ex: |
| 577 | self.log.error("Failed collecting help-message for flag %r, due to: %s", flags, ex) |
| 578 | raise |
| 579 | |
| 580 | def print_options(self) -> None: |
| 581 | """Print the options part of the help.""" |
no test coverage detected