| 2611 | return lines, lineno |
| 2612 | |
| 2613 | def _help_message_from_doc(self, doc, usage_only=False): |
| 2614 | lines = [line.strip() for line in doc.rstrip().splitlines()] |
| 2615 | if not lines: |
| 2616 | return "No help message found." |
| 2617 | if "" in lines: |
| 2618 | usage_end = lines.index("") |
| 2619 | else: |
| 2620 | usage_end = 1 |
| 2621 | formatted = [] |
| 2622 | indent = " " * len(self.prompt) |
| 2623 | for i, line in enumerate(lines): |
| 2624 | if i == 0: |
| 2625 | prefix = "Usage: " |
| 2626 | elif i < usage_end: |
| 2627 | prefix = " " |
| 2628 | else: |
| 2629 | if usage_only: |
| 2630 | break |
| 2631 | prefix = "" |
| 2632 | formatted.append(indent + prefix + line) |
| 2633 | return "\n".join(formatted) |
| 2634 | |
| 2635 | def _print_invalid_arg(self, arg): |
| 2636 | """Return the usage string for a function.""" |