@@ -60,6 +60,7 @@ func NewConsoleCmd(ec *cli.ExecutionContext) *cobra.Command {
6060 f .StringVar (& opts .Address , "address" , "localhost" , "address to serve console and migration API from" )
6161 f .BoolVar (& opts .DontOpenBrowser , "no-browser" , false , "do not automatically open console in browser" )
6262 f .StringVar (& opts .StaticDir , "static-dir" , "" , "directory where static assets mentioned in the console html template can be served from" )
63+ f .StringVar (& opts .Browser , "browser" , "" , "open console in a specific browser" )
6364
6465 f .String ("endpoint" , "" , "http(s) endpoint for Hasura GraphQL Engine" )
6566 f .String ("admin-secret" , "" , "admin secret for Hasura GraphQL Engine" )
@@ -85,6 +86,7 @@ type consoleOptions struct {
8586 WG * sync.WaitGroup
8687
8788 StaticDir string
89+ Browser string
8890}
8991
9092func (o * consoleOptions ) run () error {
@@ -166,12 +168,21 @@ func (o *consoleOptions) run() error {
166168 consoleURL := fmt .Sprintf ("http://%s:%s/" , o .Address , o .ConsolePort )
167169
168170 if ! o .DontOpenBrowser {
169- o .EC .Spin (color .CyanString ("Opening console using default browser..." ))
170- defer o .EC .Spinner .Stop ()
171+ if o .Browser != "" {
172+ o .EC .Spin (color .CyanString ("Opening console on: %s" , o .Browser ))
173+ defer o .EC .Spinner .Stop ()
174+ err = open .RunWith (consoleURL , o .Browser )
175+ if err != nil {
176+ o .EC .Logger .WithError (err ).Warnf ("failed opening console in '%s', try to open the url manually" , o .Browser )
177+ }
178+ } else {
179+ o .EC .Spin (color .CyanString ("Opening console using default browser..." ))
180+ defer o .EC .Spinner .Stop ()
171181
172- err = open .Run (consoleURL )
173- if err != nil {
174- o .EC .Logger .WithError (err ).Warn ("Error opening browser, try to open the url manually?" )
182+ err = open .Run (consoleURL )
183+ if err != nil {
184+ o .EC .Logger .WithError (err ).Warn ("Error opening browser, try to open the url manually?" )
185+ }
175186 }
176187 }
177188
0 commit comments