Skip to content

Commit

Permalink
Use pkg/browser to open URLs (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Sep 1, 2021
1 parent 7f578d8 commit 0f57d13
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 30 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
github.com/mholt/archiver/v3 v3.5.0
github.com/olekukonko/tablewriter v0.0.5
github.com/pierrec/lz4/v4 v4.1.3 // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
github.com/pkg/errors v0.9.1
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/cobra v1.1.3
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ github.com/pierrec/lz4/v4 v4.1.3 h1:/dvQpkb0o1pVlSgKNQqfkavlnXaIK+hJ0LXsKRUN9D4=
github.com/pierrec/lz4/v4 v4.1.3/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc=
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -740,6 +742,7 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand Down
4 changes: 2 additions & 2 deletions internal/branding/branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"text/template"
"time"

"github.com/auth0/auth0-cli/internal/open"
"github.com/fsnotify/fsnotify"
"github.com/guiguan/caster"
"github.com/pkg/browser"
)

// Client is a minimal representation of an auth0 Client as defined in the
Expand Down Expand Up @@ -77,7 +77,7 @@ func PreviewCustomTemplate(ctx context.Context, data TemplateData) error {
}).Encode(),
}

if err := open.URL(u.String()); err != nil {
if err := browser.OpenURL(u.String()); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/auth"
"github.com/auth0/auth0-cli/internal/open"
"github.com/auth0/auth0-cli/internal/prompt"
"github.com/spf13/cobra"
"github.com/pkg/browser"
)

func loginCmd(cli *cli) *cobra.Command {
Expand Down Expand Up @@ -51,7 +51,7 @@ func RunLogin(ctx context.Context, cli *cli, expired bool) (tenant, error) {
fmt.Printf("Your Device Confirmation code is: %s\n\n", ansi.Bold(state.UserCode))
cli.renderer.Infof("%s to open the browser to log in or %s to quit...", ansi.Green("Press Enter"), ansi.Red("^C"))
fmt.Scanln()
err = open.URL(state.VerificationURI)
err = browser.OpenURL(state.VerificationURI)

if err != nil {
cli.renderer.Warnf("Couldn't open the URL, please do it manually: %s.", state.VerificationURI)
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/utils_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/auth/authutil"
"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/open"
"github.com/auth0/auth0-cli/internal/prompt"
"gopkg.in/auth0.v5/management"
"github.com/pkg/browser"
)

const (
Expand Down Expand Up @@ -133,7 +133,7 @@ func runLoginFlow(cli *cli, t tenant, c *management.Client, connName, audience,
return err
}

if err := open.URL(loginURL); err != nil {
if err := browser.OpenURL(loginURL); err != nil {
return err
}

Expand Down Expand Up @@ -286,7 +286,7 @@ func openManageURL(cli *cli, tenant string, path string) {
cli.renderer.Warnf("Unable to format the correct URL, please ensure you have run 'auth0 login' and try again.")
return
}
if err := open.URL(fmt.Sprintf("%s%s", manageTenantURL, path)); err != nil {
if err := browser.OpenURL(fmt.Sprintf("%s%s", manageTenantURL, path)); err != nil {
cli.renderer.Warnf("Couldn't open the URL, please do it manually: %s.", manageTenantURL)
}
}
Expand Down
23 changes: 0 additions & 23 deletions internal/open/open.go

This file was deleted.

23 changes: 23 additions & 0 deletions vendor/github.com/pkg/browser/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vendor/github.com/pkg/browser/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions vendor/github.com/pkg/browser/browser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/pkg/browser/browser_darwin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/pkg/browser/browser_freebsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/pkg/browser/browser_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/pkg/browser/browser_openbsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/pkg/browser/browser_unsupported.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/github.com/pkg/browser/browser_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/pkg/browser/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/pkg/browser/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f57d13

Please sign in to comment.