Skip to content

Commit 7e8589a

Browse files
committed
feat(ui): show service URLs table after devbox start
1 parent 26b3c46 commit 7e8589a

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

cli/cmd/start.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package cmd
33
import (
44
"fmt"
55
"os"
6+
"sort"
67

78
"github.com/devboxos/devboxos/cli/internal/client"
89
"github.com/devboxos/devboxos/cli/internal/output"
10+
"github.com/devboxos/devboxos/shared/config"
911
"github.com/spf13/cobra"
1012
)
1113

@@ -58,5 +60,51 @@ func runStart(cmd *cobra.Command, args []string) error {
5860
}
5961

6062
output.Success("Environment started successfully")
63+
64+
printServiceURLs(dir)
6165
return nil
6266
}
67+
68+
func printServiceURLs(dir string) {
69+
parser := config.NewParser()
70+
cfg, err := parser.Parse(dir)
71+
if err != nil {
72+
return
73+
}
74+
75+
names := make([]string, 0, len(cfg.Services))
76+
for name := range cfg.Services {
77+
names = append(names, name)
78+
}
79+
sort.Strings(names)
80+
81+
hasURLs := false
82+
for _, name := range names {
83+
svc := cfg.Services[name]
84+
portStr := svc.Port
85+
if portStr == "" && len(svc.Ports) > 0 {
86+
portStr = svc.Ports[0]
87+
}
88+
if portStr == "" {
89+
continue
90+
}
91+
92+
hostPort := extractHostPort(portStr)
93+
if hostPort == "" {
94+
continue
95+
}
96+
97+
protocol := svc.Protocol
98+
if protocol == "" {
99+
protocol = "http"
100+
}
101+
102+
if !hasURLs {
103+
fmt.Println()
104+
output.Title("Access URLs")
105+
hasURLs = true
106+
}
107+
108+
fmt.Printf(" %-15s → %s://localhost:%s\n", name, protocol, hostPort)
109+
}
110+
}

0 commit comments

Comments
 (0)