From b0849ab260c99dd33a6c2b5d4e8855a20ad1c630 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 26 Jul 2019 16:02:16 +0200 Subject: [PATCH] remove_empty_description_od with path --- test/test_optiondescription.py | 2 +- tiramisu_cmdline_parser/api.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/test_optiondescription.py b/test/test_optiondescription.py index 908efa3..02c6e4c 100644 --- a/test/test_optiondescription.py +++ b/test/test_optiondescription.py @@ -42,7 +42,7 @@ def get_config(json, has_tree=False, default_verbosity=False, add_long=False, ad 'Sub-Tree 2', [str_]) od2 = OptionDescription('od2', - '', + None, [before, subtree, after]) root = OptionDescription('root', 'root', diff --git a/tiramisu_cmdline_parser/api.py b/tiramisu_cmdline_parser/api.py index 179e1fc..1f3571d 100644 --- a/tiramisu_cmdline_parser/api.py +++ b/tiramisu_cmdline_parser/api.py @@ -124,9 +124,15 @@ class TiramisuHelpFormatter(HelpFormatter): # Remove OD if name == description if self.items and \ self.formatter.remove_empty_description_od and \ - self.items[0][0].__name__ == '_format_text' and \ - self.items[0][1][0] == self.heading: - return '' + self.items[0][0].__name__ == '_format_text': + name = self.items[0][1][0] + path = self.heading + if '.' in path: + compare = path.rsplit('.', 1)[1] + else: + compare = path + if name == path: + return '' return super().format_help() class _TiramisuHelpAction(_HelpAction):