Return the usage string for a function.
(self, arg)
| 2633 | return "\n".join(formatted) |
| 2634 | |
| 2635 | def _print_invalid_arg(self, arg): |
| 2636 | """Return the usage string for a function.""" |
| 2637 | |
| 2638 | if not arg: |
| 2639 | self.error("Argument is required for this command") |
| 2640 | else: |
| 2641 | self.error(f"Invalid argument: {arg}") |
| 2642 | |
| 2643 | # Yes it's a bit hacky. Get the caller name, get the method based on |
| 2644 | # that name, and get the docstring from that method. |
| 2645 | # This should NOT fail if the caller is a method of this class. |
| 2646 | doc = inspect.getdoc(getattr(self, sys._getframe(1).f_code.co_name)) |
| 2647 | if doc is not None: |
| 2648 | self.message(self._help_message_from_doc(doc, usage_only=True)) |
| 2649 | |
| 2650 | # Collect all command help into docstring, if not run with -OO |
| 2651 |
no test coverage detected