Skip to content

Commit

Permalink
re-integrate changes from main
Browse files Browse the repository at this point in the history
  • Loading branch information
chaospuppy committed Jul 12, 2024
1 parent e1394e7 commit d84cc76
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ var connectCmd = &cobra.Command{
Short: lang.CmdConnectShort,
Long: lang.CmdConnectLong,
RunE: func(cmd *cobra.Command, args []string) error {
var target string
target := ""
if len(args) > 0 {
target = args[0]
}

spinner := message.NewProgressSpinner(lang.CmdConnectPreparingTunnel, target)
defer spinner.Stop()

c, err := cluster.NewCluster()
if err != nil {
return err
Expand Down Expand Up @@ -59,29 +61,28 @@ var connectCmd = &cobra.Command{
}

defer tunnel.Close()
url := tunnel.FullURL()

// Dump the tunnel URL to the console for other tools to use.
fmt.Print(url)
fmt.Print(tunnel.FullURL())

if cliOnly {
spinner.Updatef(lang.CmdConnectEstablishedCLI, url)
spinner.Updatef(lang.CmdConnectEstablishedCLI, tunnel.FullURL())
} else {
spinner.Updatef(lang.CmdConnectEstablishedWeb, url)
spinner.Updatef(lang.CmdConnectEstablishedWeb, tunnel.FullURL())

if err := exec.LaunchURL(url); err != nil {
if err := exec.LaunchURL(tunnel.FullURL()); err != nil {
message.Debug(err)
}
}

// Wait for the interrupt signal or an error.
select {
case <-ctx.Done():
spinner.Successf(lang.CmdConnectTunnelClosed, url)
spinner.Successf(lang.CmdConnectTunnelClosed, tunnel.FullURL())
return nil
case err = <-tunnel.ErrChan():
return fmt.Errorf("lost connection to the service: %w", err)
}
return nil
},
}

Expand Down

0 comments on commit d84cc76

Please sign in to comment.