diff --git a/features/project_cli_commands.feature b/features/project_cli_commands.feature index be695a2f5..b6b48be2f 100644 --- a/features/project_cli_commands.feature +++ b/features/project_cli_commands.feature @@ -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 diff --git a/features/steps/project_cli_commands_steps.py b/features/steps/project_cli_commands_steps.py index 5bb2fac6c..2a4e4e44e 100644 --- a/features/steps/project_cli_commands_steps.py +++ b/features/steps/project_cli_commands_steps.py @@ -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 # --------------------------------------------------------------------------- diff --git a/src/cleveragents/cli/commands/project.py b/src/cleveragents/cli/commands/project.py index 174a9f620..fd06e4924 100644 --- a/src/cleveragents/cli/commands/project.py +++ b/src/cleveragents/cli/commands/project.py @@ -9,7 +9,7 @@ Commands: - ``agents project unlink-resource `` - ``agents project list [--namespace NS] [REGEX]`` - ``agents project show `` -- ``agents project delete [--force] [--yes] `` +- ``agents project delete [--force|-f] [--yes|-y] `` 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."""