Skip to content

Commit

Permalink
repo delete: change confirmation flag to --yes (cli#6911)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiensedgwick authored Jan 25, 2023
1 parent a5edd8f commit 55053df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/cmd/repo/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ To authorize, run "gh auth refresh -s delete_repo"`,
if len(args) > 0 {
opts.RepoArg = args[0]
}

if !opts.IO.CanPrompt() && !opts.Confirmed {
return cmdutil.FlagErrorf("--confirm required when not running interactively")
return cmdutil.FlagErrorf("--yes required when not running interactively")
}

if runF != nil {
return runF(opts)
}

return deleteRun(opts)
},
}

cmd.Flags().BoolVar(&opts.Confirmed, "confirm", false, "confirm deletion without prompting")
_ = cmd.Flags().MarkDeprecated("confirm", "use `--yes` instead")
cmd.Flags().BoolVar(&opts.Confirmed, "yes", false, "confirm deletion without prompting")
return cmd
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/cmd/repo/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ func TestNewCmdDelete(t *testing.T) {
input: "OWNER/REPO --confirm",
output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
},
{
name: "yes flag",
tty: true,
input: "OWNER/REPO --yes",
output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
},
{
name: "no confirmation notty",
input: "OWNER/REPO",
output: DeleteOptions{RepoArg: "OWNER/REPO"},
wantErr: true,
errMsg: "--confirm required when not running interactively",
errMsg: "--yes required when not running interactively",
},
{
name: "base repo resolution",
Expand Down

0 comments on commit 55053df

Please sign in to comment.