From 839b0e7230abdd97a807cc8505728d7dcd6d63f4 Mon Sep 17 00:00:00 2001 From: Thomas Moschny Date: Tue, 8 Feb 2022 16:29:43 +0100 Subject: [PATCH] Add default help text for options taking a generic resource argument. fixes #387 --- CHANGES/387.doc | 1 + pulpcore/cli/common/generic.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 CHANGES/387.doc diff --git a/CHANGES/387.doc b/CHANGES/387.doc new file mode 100644 index 000000000..2dd74eee9 --- /dev/null +++ b/CHANGES/387.doc @@ -0,0 +1 @@ +Improve help text for options taking a generic resource argument. diff --git a/pulpcore/cli/common/generic.py b/pulpcore/cli/common/generic.py index 578b99c29..301c6b661 100644 --- a/pulpcore/cli/common/generic.py +++ b/pulpcore/cli/common/generic.py @@ -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} or by href. " + "{plugin_default}{type_default}" + ).format( + plugin_form=_("[:]") if default_plugin else _(""), + type_form=_("[:]") if default_type else _(""), + plugin_default=_("'' defaults to {plugin}. ").format(plugin=default_plugin) + if default_plugin + else "", + type_default=_("'' defaults to {type}. ").format(type=default_type) + if default_type + else "", + ) + return click.option(*args, **kwargs)