mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
Co-authored-by: Ashish Rao <ashishrao@hasura.io> Co-authored-by: Thibaut Tiberghien <thibaut@smplrspace.com>
This commit is contained in:
parent
2aba7edf81
commit
2fc49eaa63
@ -15,11 +15,10 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/telemetry"
|
||||
"github.com/hasura/graphql-engine/cli/util"
|
||||
|
||||
"github.com/briandowns/spinner"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/hasura/graphql-engine/cli/telemetry"
|
||||
"github.com/hasura/graphql-engine/cli/util"
|
||||
"github.com/hasura/graphql-engine/cli/version"
|
||||
"github.com/mattn/go-colorable"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -60,6 +60,7 @@ func NewConsoleCmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
f.StringVar(&opts.Address, "address", "localhost", "address to serve console and migration API from")
|
||||
f.BoolVar(&opts.DontOpenBrowser, "no-browser", false, "do not automatically open console in browser")
|
||||
f.StringVar(&opts.StaticDir, "static-dir", "", "directory where static assets mentioned in the console html template can be served from")
|
||||
f.StringVar(&opts.Browser, "browser", "", "open console in a specific browser")
|
||||
|
||||
f.String("endpoint", "", "http(s) endpoint for Hasura GraphQL Engine")
|
||||
f.String("admin-secret", "", "admin secret for Hasura GraphQL Engine")
|
||||
@ -85,6 +86,7 @@ type consoleOptions struct {
|
||||
WG *sync.WaitGroup
|
||||
|
||||
StaticDir string
|
||||
Browser string
|
||||
}
|
||||
|
||||
func (o *consoleOptions) run() error {
|
||||
@ -166,12 +168,21 @@ func (o *consoleOptions) run() error {
|
||||
consoleURL := fmt.Sprintf("http://%s:%s/", o.Address, o.ConsolePort)
|
||||
|
||||
if !o.DontOpenBrowser {
|
||||
o.EC.Spin(color.CyanString("Opening console using default browser..."))
|
||||
defer o.EC.Spinner.Stop()
|
||||
if o.Browser != "" {
|
||||
o.EC.Spin(color.CyanString("Opening console on: %s", o.Browser))
|
||||
defer o.EC.Spinner.Stop()
|
||||
err = open.RunWith(consoleURL, o.Browser)
|
||||
if err != nil {
|
||||
o.EC.Logger.WithError(err).Warnf("failed opening console in '%s', try to open the url manually", o.Browser)
|
||||
}
|
||||
} else {
|
||||
o.EC.Spin(color.CyanString("Opening console using default browser..."))
|
||||
defer o.EC.Spinner.Stop()
|
||||
|
||||
err = open.Run(consoleURL)
|
||||
if err != nil {
|
||||
o.EC.Logger.WithError(err).Warn("Error opening browser, try to open the url manually?")
|
||||
err = open.Run(consoleURL)
|
||||
if err != nil {
|
||||
o.EC.Logger.WithError(err).Warn("Error opening browser, try to open the url manually?")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
|
||||
mt "github.com/hasura/graphql-engine/cli/migrate/testing"
|
||||
"github.com/hasura/graphql-engine/cli/version"
|
||||
_ "github.com/lib/pq"
|
||||
|
Loading…
Reference in New Issue
Block a user