diff --git a/CHANGES/236.feature b/CHANGES/236.feature new file mode 100644 index 000000000..e8bf42f37 --- /dev/null +++ b/CHANGES/236.feature @@ -0,0 +1 @@ +Added ``--force`` as the inverse of ``--dry-run`` and started to allow ``dry_run`` in the settings. diff --git a/pulpcore/cli/common/__init__.py b/pulpcore/cli/common/__init__.py index e655c5086..39f980519 100644 --- a/pulpcore/cli/common/__init__.py +++ b/pulpcore/cli/common/__init__.py @@ -26,6 +26,8 @@ def _validate_config(config: Dict[str, Any]) -> bool: if "format" in config and config["format"].lower() not in FORMAT_CHOICES: raise ValueError(_("'format' is not one of {}").format(FORMAT_CHOICES)) + if "dry_run" in config and not isinstance(config["dry_run"], bool): + raise ValueError(_("'dry_run' is not a bool")) return True @@ -84,6 +86,9 @@ def _config_callback(ctx: click.Context, param: Any, value: Optional[str]) -> No default="json", help=_("Format of the response"), ), + click.option( + "--dry-run/--force", is_flag=True, help=_("Trace commands without performing any unsafe HTTP calls") + ), ] @@ -124,9 +129,6 @@ def config_options(command: Callable[..., Any]) -> Callable[..., Any]: help=_("Start tasks in the background instead of awaiting them"), ) @click.option("--refresh-api", is_flag=True, help=_("Invalidate cached API docs")) -@click.option( - "--dry-run", is_flag=True, help=_("Trace commands without performing any unsafe HTTP calls") -) @config_options @click.pass_context def main(