Skip to content

Commit

Permalink
Make dry_run a setting and --force its inverse
Browse files Browse the repository at this point in the history
fixes pulp#236
  • Loading branch information
mdellweg committed May 12, 2021
1 parent d777f3b commit 8f008e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/236.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added ``--force`` as the inverse of ``--dry-run`` and started to allow ``dry_run`` in the settings.
8 changes: 5 additions & 3 deletions pulpcore/cli/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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")
),
]


Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8f008e5

Please sign in to comment.