fix(cli): resolve --force/-f short form conflict on project delete #1263
@@ -212,3 +212,10 @@ Feature: Project CLI command functions coverage
|
||||
When I invoke project-delete for "local/del-force" with yes and force
|
||||
Then the project cmd output should contain "deleted"
|
||||
And the project cmd should succeed
|
||||
|
||||
Scenario: delete command accepts -f short form for --force
|
||||
Given a project "local/del-sf" is created in the commands DB
|
||||
And a resource is linked to project "local/del-sf" in the commands DB
|
||||
When I invoke project-delete for "local/del-sf" with yes and short force flag
|
||||
Then the project cmd output should contain "deleted"
|
||||
And the project cmd should succeed
|
||||
|
||||
@@ -630,6 +630,27 @@ def step_invoke_delete_force(context: Any, name: str) -> None:
|
||||
_capture(context, delete, name=name, yes=True, force=True)
|
||||
|
||||
|
||||
@when('I invoke project-delete for "{name}" with yes and short force flag')
|
||||
def step_invoke_delete_short_force(context: Any, name: str) -> None:
|
||||
"""Invoke 'project delete' via CliRunner using the ``-f`` short flag.
|
||||
|
||||
This validates that the CLI argument parser correctly maps ``-f`` to
|
||||
``--force`` (not ``--format``), matching the specification.
|
||||
"""
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from cleveragents.cli.commands.project import app as project_app
|
||||
|
||||
_patch_project_mod(context)
|
||||
try:
|
||||
cli_runner = CliRunner()
|
||||
result = cli_runner.invoke(project_app, ["delete", name, "--yes", "-f"])
|
||||
context._cmd_output = result.output
|
||||
context._cmd_failed = result.exit_code != 0
|
||||
finally:
|
||||
_unpatch_project_mod()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Then assertions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -9,7 +9,7 @@ Commands:
|
||||
- ``agents project unlink-resource <project> <resource>``
|
||||
- ``agents project list [--namespace NS] [REGEX]``
|
||||
- ``agents project show <project>``
|
||||
- ``agents project delete [--force] [--yes] <name>``
|
||||
- ``agents project delete [--force|-f] [--yes|-y] <name>``
|
||||
|
||||
Legacy file-filter sub-app is preserved for backward compatibility.
|
||||
|
||||
@@ -930,7 +930,7 @@ def delete(
|
||||
],
|
||||
force: Annotated[
|
||||
bool,
|
||||
typer.Option("--force", help="Force delete even if resources are linked"),
|
||||
typer.Option("--force", "-f", help="Force delete even if resources are linked"),
|
||||
] = False,
|
||||
yes: Annotated[
|
||||
bool,
|
||||
@@ -938,7 +938,7 @@ def delete(
|
||||
] = False,
|
||||
output_format: Annotated[
|
||||
str,
|
||||
typer.Option("--format", "-f", help=_FORMAT_HELP),
|
||||
typer.Option("--format", help=_FORMAT_HELP),
|
||||
] = "rich",
|
||||
) -> None:
|
||||
"""Delete a project from the registry."""
|
||||
|
||||
Reference in New Issue
Block a user