Skip to content

Commit

Permalink
Refactor: help: rename HelpEntry.long to HelEntry.long_help
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Sep 6, 2024
1 parent 4e8e1e2 commit 2d2b9e9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crmsh/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def __init__(self, short_help, long_help='', alias_for=None, generated=False):
self.generated = generated

@property
def long(self):
def long_help(self):
return self._long_help

@long.setter
def long(self, value):
@long_help.setter
def long_help(self, value):
self._long_help = value

def is_alias(self):
Expand All @@ -104,7 +104,7 @@ def paginate(self):
helpfilter = HelpFilter()

short_help = clidisplay.help_header(self.short)
long_help = self.long
long_help = self.long_help
if long_help:
long_help = helpfilter(long_help)
if not long_help.startswith('\n'):
Expand All @@ -117,8 +117,8 @@ def paginate(self):
page_string(short_help + '\n' + prefix + long_help)

def __str__(self):
if self.long:
return self.short + '\n' + self.long
if self.long_help:
return self.short + '\n' + self.long_help
return self.short

def __repr__(self):
Expand All @@ -137,15 +137,15 @@ def __init__(
self._cmd_args = cmd_args

@functools.cached_property
def long(self):
def long_help(self):
args = ['crm']
args.extend(self._cmd_args)
args.append('--help-without-redirect')
rc, stdout, _ = ShellUtils.get_stdout_stderr(args, shell=False, mix_stderr=True)
return stdout

def paginate(self):
page_string('{}\n\n{}'.format(self.short, self.long))
page_string('{}\n\n{}'.format(self.short, self.long_help))


@dataclasses.dataclass
Expand Down Expand Up @@ -412,7 +412,7 @@ def append_subcommand_list_to_long_description(node: SubcommandTreeNode):
if isinstance(node.help, LazyHelpEntryFromCli) or not node.children:
return
buf = io.StringIO()
buf.write(node.help.long)
buf.write(node.help.long_help)
buf.write('\n\nCommands:\n')
max_width = get_max_width(node.children)
for name, child in sorted(node.children.items(), key=lambda x: (bool(x[1].children), x[0])):
Expand All @@ -421,7 +421,7 @@ def append_subcommand_list_to_long_description(node: SubcommandTreeNode):
buf.write('\t')
buf.write(_titleline(name, child.help.short, width=max_width))
append_subcommand_list_to_long_description(child)
node.help.long = buf.getvalue()
node.help.long_help = buf.getvalue()

def fixup_help_aliases(help_node: SubcommandTreeNode, childinfo):
"add help for aliases"
Expand Down

0 comments on commit 2d2b9e9

Please sign in to comment.