From a51422bc5343f6dfa1d2093338624da1b4b46f77 Mon Sep 17 00:00:00 2001 From: KirtiRamchandani Date: Sun, 31 May 2026 23:09:27 +0530 Subject: [PATCH] fix(app delete): reject positional app names --- internal/pkg/cli/app_delete.go | 3 ++- internal/pkg/cli/app_delete_test.go | 12 ++++++++++++ site/content/docs/commands/app-delete.en.md | 14 +++++++++----- site/content/docs/commands/app-delete.ja.md | 12 ++++++++---- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/internal/pkg/cli/app_delete.go b/internal/pkg/cli/app_delete.go index 9ff1567457e..47a53ecaf25 100644 --- a/internal/pkg/cli/app_delete.go +++ b/internal/pkg/cli/app_delete.go @@ -398,9 +398,10 @@ func buildAppDeleteCommand() *cobra.Command { cmd := &cobra.Command{ Use: "delete", Short: "Delete all resources associated with the application.", + Args: cobra.NoArgs, Example: ` Force delete the application with environments "test" and "prod". - /code $ copilot app delete --yes`, + /code $ copilot app delete --name phonetool --yes`, RunE: runCmdE(func(cmd *cobra.Command, args []string) error { opts, err := newDeleteAppOpts(vars) if err != nil { diff --git a/internal/pkg/cli/app_delete_test.go b/internal/pkg/cli/app_delete_test.go index 3a53c391cec..8eb26c808a8 100644 --- a/internal/pkg/cli/app_delete_test.go +++ b/internal/pkg/cli/app_delete_test.go @@ -6,6 +6,7 @@ package cli import ( "errors" "fmt" + "io" "testing" "github.com/aws/aws-sdk-go/aws/session" @@ -21,6 +22,17 @@ import ( "github.com/stretchr/testify/require" ) +func TestAppDeleteCommandRejectsPositionalAppName(t *testing.T) { + cmd := buildAppDeleteCommand() + cmd.SetArgs([]string{"phonetool"}) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + + err := cmd.Execute() + + require.EqualError(t, err, `unknown command "phonetool" for "delete"`) +} + type deleteAppMocks struct { spinner *mocks.Mockprogress store *mocks.Mockstore diff --git a/site/content/docs/commands/app-delete.en.md b/site/content/docs/commands/app-delete.en.md index 1d66f3ead34..b657d036372 100644 --- a/site/content/docs/commands/app-delete.en.md +++ b/site/content/docs/commands/app-delete.en.md @@ -10,12 +10,16 @@ $ copilot app delete [flags] ## What are the flags? ``` --h, --help help for delete - --yes Skips confirmation prompt. +-h, --help help for delete +-n, --name string Name of the application. + --yes Skips confirmation prompt. ``` ## Examples -Force delete the application. +!!!warning "Use `--name` for application names" + `copilot app delete` does not accept a positional application name. To delete a specific application, pass the name with `--name`. + +Force delete an application named "phonetool". ```console -$ copilot app delete --yes -``` \ No newline at end of file +$ copilot app delete --name phonetool --yes +``` diff --git a/site/content/docs/commands/app-delete.ja.md b/site/content/docs/commands/app-delete.ja.md index 7b50d4529d6..385d0b421f4 100644 --- a/site/content/docs/commands/app-delete.ja.md +++ b/site/content/docs/commands/app-delete.ja.md @@ -10,12 +10,16 @@ $ copilot app delete [flags] ## フラグ ``` --h, --help help for delete - --yes Skips confirmation prompt. +-h, --help help for delete +-n, --name string Name of the application. + --yes Skips confirmation prompt. ``` ## 実行例 -Application を強制的に削除します。 +!!!warning "Application 名には `--name` を使用してください" + `copilot app delete` は位置引数の Application 名を受け付けません。特定の Application を削除するには、`--name` で名前を渡します。 + +"phonetool" という名前の Application を強制的に削除します。 ```console -$ copilot app delete --yes +$ copilot app delete --name phonetool --yes ```