Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/onecli/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
Loading