@@ -24,6 +24,7 @@ type hookOptions struct {
2424 Host string
2525 EventTypes []string
2626 Repo string
27+ Org string
2728 Port int
2829}
2930
@@ -33,22 +34,23 @@ func NewCmdForward(runF func(*hookOptions) error) *cobra.Command {
3334 Out : os .Stdout ,
3435 }
3536 cmd := & cobra.Command {
36- Use : "forward --events=<event_types> --repo=<repo> [--port=<port>] [--host=<host>]" ,
37+ Use : "forward --events=<event_types> --repo|org =<repo|org > [--port=<port>] [--host=<host>]" ,
3738 Short : "Receive test events on a server running locally" ,
3839 Long : heredoc .Doc (`To output event payloads to stdout instead of sending to a server,
3940 omit the --port flag. If the --host flag is not specified, webhooks will be created against github.com` ),
4041 Example : heredoc .Doc (`
4142 # create a dev webhook for the 'issue_open' event in the monalisa/smile repo in GitHub running locally, and
4243 # forward payloads for the triggered event to localhost:9999
4344
44- $ gh webhooks forward --events=issue_open --repo=monalisa/smile --port=9999 --host=api.github.localhost
45+ $ gh webhooks forward --events=issues --repo=monalisa/smile --port=9999
46+ $ gh webhooks forward --events=issues --org=github --port=9999
4547 ` ),
4648 RunE : func (* cobra.Command , []string ) error {
4749 if opts .EventTypes == nil {
4850 return cmdutil .FlagErrorf ("`--events` flag required" )
4951 }
50- if opts .Repo == "" {
51- return cmdutil .FlagErrorf ("`--repo` flag required" )
52+ if opts .Repo == "" && opts . Org == "" {
53+ return cmdutil .FlagErrorf ("`--repo` or `--org` flag required" )
5254 }
5355 if opts .Host == "" {
5456 opts .Host = gitHubAPIProdURL
@@ -83,9 +85,10 @@ func NewCmdForward(runF func(*hookOptions) error) *cobra.Command {
8385 },
8486 }
8587 cmd .Flags ().StringSliceVarP (& opts .EventTypes , "events" , "E" , []string {}, "(required) Names of the event types to forward" )
86- cmd .Flags ().StringVarP (& opts .Repo , "repo" , "R" , "" , "(required) Name of the repo where the webhook is installed" )
88+ cmd .Flags ().StringVarP (& opts .Repo , "repo" , "R" , "" , "Name of the repo where the webhook is installed" )
8789 cmd .Flags ().IntVarP (& opts .Port , "port" , "P" , 0 , "(optional) Local port where the server which will receive webhooks is running" )
8890 cmd .Flags ().StringVarP (& opts .Host , "host" , "H" , "" , "(optional) Host address of GitHub API, default: api.github.com" )
91+ cmd .Flags ().StringVarP (& opts .Org , "org" , "O" , "" , "Name of the org where the webhook is installed" )
8992 return cmd
9093}
9194
@@ -100,9 +103,11 @@ func runFwd(out io.Writer, port int, token, wsURL string, activateHook func() er
100103 if err != nil {
101104 // If the error is a server disconnect (1006), retry connecting
102105 if websocket .IsCloseError (err , websocket .CloseAbnormalClosure ) {
106+ fmt .Println ("ABNORMAL CLOSURE" )
103107 time .Sleep (5 * time .Second )
104108 continue
105109 }
110+ fmt .Println ("BRUH" , err )
106111 return err
107112 }
108113 }
0 commit comments