@@ -18,6 +18,7 @@ import (
1818
1919type DeleteOptions struct {
2020 HttpClient func () (* http.Client , error )
21+ BaseRepo func () (ghrepo.Interface , error )
2122 IO * iostreams.IOStreams
2223 RepoArg string
2324 Confirmed bool
@@ -30,15 +31,17 @@ func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Co
3031 }
3132
3233 cmd := & cobra.Command {
33- Use : "delete <repository>" ,
34+ Use : "delete [ <repository>] " ,
3435 Short : "Delete a repository" ,
3536 Long : `Delete a GitHub repository.
3637
3738Deletion requires authorization with the "delete_repo" scope.
3839To authorize, run "gh auth refresh -s delete_repo"` ,
39- Args : cmdutil . ExactArgs ( 1 , "cannot delete: repository argument required" ),
40+ Args : cobra . MaximumNArgs ( 1 ),
4041 RunE : func (cmd * cobra.Command , args []string ) error {
41- opts .RepoArg = args [0 ]
42+ if len (args ) > 0 {
43+ opts .RepoArg = args [0 ]
44+ }
4245 if ! opts .IO .CanPrompt () && ! opts .Confirmed {
4346 return cmdutil .FlagErrorf ("could not prompt: confirmation with prompt or --confirm flag required" )
4447 }
@@ -60,8 +63,15 @@ func deleteRun(opts *DeleteOptions) error {
6063 }
6164 apiClient := api .NewClientFromHTTP (httpClient )
6265
63- repoSelector := opts .RepoArg
6466 var toDelete ghrepo.Interface
67+ repoSelector := opts .RepoArg
68+ if repoSelector == "" {
69+ currRepo , err := opts .BaseRepo ()
70+ if err != nil {
71+ return err
72+ }
73+ repoSelector = ghrepo .FullName (currRepo )
74+ }
6575
6676 if ! strings .Contains (repoSelector , "/" ) {
6777 currentUser , err := api .CurrentLoginName (apiClient , ghinstance .Default ())
0 commit comments