From 6cfa36019711d9bbdc1abb1cadf3f4fc1daf6138 Mon Sep 17 00:00:00 2001 From: johnnyfish Date: Tue, 19 May 2026 01:37:10 +0300 Subject: [PATCH] fix: require --confirm flag for project deletion --- cmd/onecli/projects.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/onecli/projects.go b/cmd/onecli/projects.go index 659d912..49b2634 100644 --- a/cmd/onecli/projects.go +++ b/cmd/onecli/projects.go @@ -139,8 +139,9 @@ func (c *ProjectsUpdateCmd) Run(out *output.Writer) error { // ProjectsDeleteCmd is `onecli projects delete`. type ProjectsDeleteCmd struct { - ID string `required:"" help:"ID of the project to delete."` - DryRun bool `optional:"" name:"dry-run" help:"Validate the request without executing it."` + ID string `required:"" help:"ID of the project to delete."` + Confirm string `optional:"" help:"Project ID to confirm deletion. Required for destructive operation."` + DryRun bool `optional:"" name:"dry-run" help:"Validate the request without executing it."` } func (c *ProjectsDeleteCmd) Run(out *output.Writer) error { @@ -150,10 +151,16 @@ func (c *ProjectsDeleteCmd) Run(out *output.Writer) error { if c.DryRun { return out.WriteDryRun("Would delete project", map[string]string{"id": c.ID}) } + + if c.Confirm != c.ID { + return fmt.Errorf("confirmation failed: pass --confirm %q to delete this project and all its data", c.ID) + } + client, err := newClient() if err != nil { return err } + if err := client.DeleteProject(newContext(), c.ID); err != nil { return err }