Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[crmsh-4.6] Dev: help: Support '--help' option for cluster properties #1648

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions crmsh/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,18 @@ def do_quit(self, context):
....
''')
@completer(_help_completer)
def do_help(self, context, subject=None, subtopic=None):
def do_help(self, context, *args):
"""usage: help topic|level|command"""
h = help_module.help_contextual(context.level_name(), subject, subtopic)
h.paginate()
subject, subtopic = None, None
other_args = []
if args:
subject = args[0]
if len(args) >= 2:
subtopic = args[1]
other_args = args[2:]
h = help_module.help_contextual(context.level_name(), subject, subtopic, other_args)
if h:
h.paginate()
context.command_name = ""

def get_completions(self):
Expand Down
17 changes: 16 additions & 1 deletion crmsh/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from . import config
from . import clidisplay
from .ordereddict import odict
from . import ra
from . import log


Expand Down Expand Up @@ -261,11 +262,25 @@
return fuzzy_get(_LEVELS, level)


def help_contextual(context, subject, subtopic):
def _is_property(level, command, args):
return level == 'configure' and command == 'property' and len(args) == 1


def help_contextual(context, subject, subtopic, args):
"""
Returns contextual help
"""
_load_help()
if _is_property(subject, subtopic, args):
property_name = args[0]
agent = ra.get_properties_meta()
if agent:
all_properties = agent.params()
if property_name in all_properties:
print(agent.meta_parameter(property_name))

Check warning on line 280 in crmsh/help.py

View check run for this annotation

Codecov / codecov/patch

crmsh/help.py#L275-L280

Added lines #L275 - L280 were not covered by tests
else:
raise ValueError(f"Unknown property '{property_name}'")
return None

Check warning on line 283 in crmsh/help.py

View check run for this annotation

Codecov / codecov/patch

crmsh/help.py#L282-L283

Added lines #L282 - L283 were not covered by tests
if subject is None:
if context == 'root':
return help_overview()
Expand Down
3 changes: 3 additions & 0 deletions crmsh/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,9 @@
def do_property(self, context, *args):
"usage: property [$id=<set_id>] <option>=<value>"
self.__override_lower_level_attrs(*args)
if not args:
utils.multicolumn(ra.get_properties_list())
return

Check warning on line 1130 in crmsh/ui_configure.py

View check run for this annotation

Codecov / codecov/patch

crmsh/ui_configure.py#L1129-L1130

Added lines #L1129 - L1130 were not covered by tests
return self.__conf_object(context.get_command_name(), *args)

@command.skill_level('administrator')
Expand Down
7 changes: 7 additions & 0 deletions doc/crm.8.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3513,6 +3513,12 @@ When setting the +maintenance-mode+ property, it will
inform the user if there are nodes or resources that
have the +maintenance+ property.

If no property name is passed to the command, the list of known
cluster properties is printed.

To print one property's help, use the +--help+ option; Or use <Tab>
to complete the help text for the property on interactive mode.

For more information on rule expressions, see
<<topics_Syntax_RuleExpressions,Syntax: Rule expressions>>.

Expand All @@ -3522,6 +3528,7 @@ property [<set_id>:] [rule ...] <option>=<value> [<option>=<value> ...]
...............
Example:
...............
property stonith-enabled --help
property stonith-enabled=true
property rule date spec years=2014 stonith-enabled=false
...............
Expand Down
Loading