Skip to content

Commit

Permalink
Add default help text for options taking a generic resource argument.
Browse files Browse the repository at this point in the history
fixes pulp#387
  • Loading branch information
thmo committed Feb 8, 2022
1 parent 4740fbd commit 839b0e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/387.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve help text for options taking a generic resource argument.
16 changes: 16 additions & 0 deletions pulpcore/cli/common/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,22 @@ def _multi_option_callback(
kwargs["callback"] = _multi_option_callback
else:
kwargs["callback"] = _option_callback

if "help" not in kwargs:
kwargs["help"] = _(
"Referenced resource, in the form {plugin_form}{type_form}<name> or by href. "
"{plugin_default}{type_default}"
).format(
plugin_form=_("[<plugin>:]") if default_plugin else _("<plugin>"),
type_form=_("[<resource_type>:]") if default_type else _("<resource_type>"),
plugin_default=_("'<plugin>' defaults to {plugin}. ").format(plugin=default_plugin)
if default_plugin
else "",
type_default=_("'<resource_type>' defaults to {type}. ").format(type=default_type)
if default_type
else "",
)

return click.option(*args, **kwargs)


Expand Down

0 comments on commit 839b0e7

Please sign in to comment.