44 "fmt"
55 "net/http"
66
7- "github.com/MakeNowJust/heredoc"
87 "github.com/cli/cli/api"
98 "github.com/cli/cli/internal/ghinstance"
109 "github.com/cli/cli/internal/ghrepo"
@@ -31,12 +30,7 @@ func NewCmdRemove(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co
3130 cmd := & cobra.Command {
3231 Use : "remove <secret name>" ,
3332 Short : "Remove an organization or repository secret" ,
34- Example : heredoc .Doc (`
35- $ gh secret remove REPO_SECRET
36- $ gh secret remove --org ORG_SECRET
37- $ gh secret remove --org="anotherOrg" ORG_SECRET
38- ` ),
39- Args : cobra .ExactArgs (1 ),
33+ Args : cobra .ExactArgs (1 ),
4034 RunE : func (cmd * cobra.Command , args []string ) error {
4135 // support `-R, --repo` override
4236 opts .BaseRepo = f .BaseRepo
@@ -50,8 +44,7 @@ func NewCmdRemove(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co
5044 return removeRun (opts )
5145 },
5246 }
53- cmd .Flags ().StringVar (& opts .OrgName , "org" , "" , "List secrets for an organization" )
54- cmd .Flags ().Lookup ("org" ).NoOptDefVal = "@owner"
47+ cmd .Flags ().StringVarP (& opts .OrgName , "org" , "o" , "" , "List secrets for an organization" )
5548
5649 return cmd
5750}
@@ -63,27 +56,24 @@ func removeRun(opts *RemoveOptions) error {
6356 }
6457 client := api .NewClientFromHTTP (c )
6558
59+ orgName := opts .OrgName
60+
6661 var baseRepo ghrepo.Interface
67- if opts . OrgName == "" || opts . OrgName == "@owner " {
62+ if orgName == "" {
6863 baseRepo , err = opts .BaseRepo ()
6964 if err != nil {
7065 return fmt .Errorf ("could not determine base repo: %w" , err )
7166 }
7267 }
7368
74- host := ghinstance .OverridableDefault ()
75- if opts .OrgName == "@owner" {
76- opts .OrgName = baseRepo .RepoOwner ()
77- host = baseRepo .RepoHost ()
78- }
79-
8069 var path string
8170 if opts .OrgName == "" {
8271 path = fmt .Sprintf ("repos/%s/actions/secrets/%s" , ghrepo .FullName (baseRepo ), opts .SecretName )
8372 } else {
8473 path = fmt .Sprintf ("orgs/%s/actions/secrets/%s" , opts .OrgName , opts .SecretName )
8574 }
8675
76+ host := ghinstance .OverridableDefault ()
8777 err = client .REST (host , "DELETE" , path , nil , nil )
8878 if err != nil {
8979 return fmt .Errorf ("failed to delete secret %s: %w" , opts .SecretName , err )
0 commit comments