Skip to content

Commit

Permalink
Fix: help: crm help <topic> does not work (#1567)
Browse files Browse the repository at this point in the history
1. When len(args) is 1, should check if it is a topic first.
2. Should check _is_command() or _is_level() before calling
   help_command().
3. Refine the error message printed when no suitable help entries are
   found.

Fixes #1567.
  • Loading branch information
nicholasyang2022 committed Sep 27, 2024
1 parent e5c5acf commit 61322a8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crmsh/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,18 @@ def help_contextual(levels: typing.Sequence[str]):
_load_help()
if len(levels) == 0:
return help_overview()
elif len(levels) == 1:
return help_command(levels[0:])
elif _is_help_topic(levels[0]):
topic = levels[0]
return help_topic(topic)
elif len(levels) == 1 and _is_help_topic(levels[0]):
return help_topic(levels[0])

Check warning on line 324 in crmsh/help.py

View check run for this annotation

Codecov / codecov/patch

crmsh/help.py#L324

Added line #L324 was not covered by tests
elif _is_command(levels) or _is_level(levels):
return help_command(levels)
return help_command(levels[0:])
else:
topic = levels[0].lower()
t = fuzzy_get(_TOPICS, topic)
if t:
return t
raise ValueError("No help found for '%s'! 'overview' lists all help entries" % (topic))
raise ValueError('No help found for "crm {}". Run "crm help overview" to list all help entries.'.format(

Check warning on line 332 in crmsh/help.py

View check run for this annotation

Codecov / codecov/patch

crmsh/help.py#L332

Added line #L332 was not covered by tests
' '.join(levels),
))


def add_help(levels: typing.Sequence[str], entry):
Expand Down

0 comments on commit 61322a8

Please sign in to comment.