Skip to content

Commit eac5b4f

Browse files
authored
fix: require --confirm flag for project deletion (#57)
1 parent 543f456 commit eac5b4f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cmd/onecli/projects.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ func (c *ProjectsUpdateCmd) Run(out *output.Writer) error {
139139

140140
// ProjectsDeleteCmd is `onecli projects delete`.
141141
type ProjectsDeleteCmd struct {
142-
ID string `required:"" help:"ID of the project to delete."`
143-
DryRun bool `optional:"" name:"dry-run" help:"Validate the request without executing it."`
142+
ID string `required:"" help:"ID of the project to delete."`
143+
Confirm string `optional:"" help:"Project ID to confirm deletion. Required for destructive operation."`
144+
DryRun bool `optional:"" name:"dry-run" help:"Validate the request without executing it."`
144145
}
145146

146147
func (c *ProjectsDeleteCmd) Run(out *output.Writer) error {
@@ -150,10 +151,16 @@ func (c *ProjectsDeleteCmd) Run(out *output.Writer) error {
150151
if c.DryRun {
151152
return out.WriteDryRun("Would delete project", map[string]string{"id": c.ID})
152153
}
154+
155+
if c.Confirm != c.ID {
156+
return fmt.Errorf("confirmation failed: pass --confirm %q to delete this project and all its data", c.ID)
157+
}
158+
153159
client, err := newClient()
154160
if err != nil {
155161
return err
156162
}
163+
157164
if err := client.DeleteProject(newContext(), c.ID); err != nil {
158165
return err
159166
}

0 commit comments

Comments
 (0)