From d2015d808bdc267a2d53c7520739804be5c8a6a0 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 22 Aug 2022 13:41:08 +0200 Subject: [PATCH] Do not crash when do_* handler has no docstring --- osc/cmdln.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/osc/cmdln.py b/osc/cmdln.py index fafc3013..bb346dd6 100644 --- a/osc/cmdln.py +++ b/osc/cmdln.py @@ -143,16 +143,20 @@ class Cmdln: self.cmd_map[i] = cmd_func self.alias_to_cmd_name_map[i] = cmd_name - # split doctext into lines, allow the first line to start at a new line - help_lines = cmd_func.__doc__.lstrip().splitlines() + if cmd_func.__doc__: + # split doctext into lines, allow the first line to start at a new line + help_lines = cmd_func.__doc__.lstrip().splitlines() - # use the first line as help text - help_text = help_lines.pop(0) + # use the first line as help text + help_text = help_lines.pop(0) - # use the remaining lines as description - help_lines = self._remove_leading_spaces_from_lines(help_lines) - help_desc = "\n".join(help_lines) - help_desc = help_desc.strip() + # use the remaining lines as description + help_lines = self._remove_leading_spaces_from_lines(help_lines) + help_desc = "\n".join(help_lines) + help_desc = help_desc.strip() + else: + help_text = "" + help_desc = "" if hidden: help_text = argparse.SUPPRESS