@@ -13,9 +13,7 @@ import (
1313
1414type (
1515 // DeleteRepoOpts are the flags for the delete repo command
16- DeleteRepoOpts struct {
17- Name string
18- }
16+ DeleteRepoOpts struct {}
1917)
2018
2119// NewDeleteRepoCmd creates a new delete repo command
@@ -25,17 +23,16 @@ func NewDeleteRepoCmd(ctx context.Context) *cobra.Command {
2523 Use : "delete" ,
2624 Short : "Deletes a github repository" ,
2725 RunE : func (cmd * cobra.Command , args []string ) error {
28- return RunDeleteRepo (ctx , opts )
26+ return RunDeleteRepo (ctx , args [ 0 ], opts )
2927 },
28+ Args : cobra .MinimumNArgs (1 ),
3029 }
3130
32- cmd .Flags ().StringVarP (& opts .Name , "name" , "n" , "" , "The name of the repository" )
33-
3431 return cmd
3532}
3633
3734// RunDeleteRepo runs the command to delete a repository
38- func RunDeleteRepo (ctx context.Context , opts * DeleteRepoOpts ) error {
35+ func RunDeleteRepo (ctx context.Context , name string , opts * DeleteRepoOpts ) error {
3936 logger := log .WithContext (ctx )
4037 cfg := config .WithContext (ctx )
4138 githubClient := gh .WithContext (ctx )
@@ -48,12 +45,12 @@ func RunDeleteRepo(ctx context.Context, opts *DeleteRepoOpts) error {
4845 return errors .New ("please provide an organization" )
4946 }
5047
51- _ , err := githubClient .Repositories .Delete (ctx , org , opts . Name )
48+ _ , err := githubClient .Repositories .Delete (ctx , org , name )
5249 if err != nil {
5350 return errwrap .Wrapf ("Could not delete repository: {{err}}" , err )
5451 }
5552
56- logger .Info ("Repository %s deleted!" , opts . Name )
53+ logger .Infof ("Repository %s deleted!" , name )
5754
5855 return nil
5956}
0 commit comments