Skip to content

Commit 7cbdcd8

Browse files
committed
Add --open to server:start command
1 parent afef23c commit 7cbdcd8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

commands/local_server_start.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var localServerStartCmd = &console.Command{
6464
project.ConfigurationFlags,
6565
dirFlag,
6666
&console.BoolFlag{Name: "no-humanize", Usage: "Do not format JSON logs"},
67+
&console.BoolFlag{Name: "open", Usage: "Open the application in the browser after starting the server"},
6768
),
6869
Action: func(c *console.Context) error {
6970
ui := terminal.SymfonyStyle(terminal.Stdout, terminal.Stdin)
@@ -274,11 +275,21 @@ var localServerStartCmd = &console.Command{
274275
if p.PHPServer != nil {
275276
msg += fmt.Sprintf(" The Web server is using %s %s\n", p.PHPServer.Version.ServerTypeName(), p.PHPServer.Version.Version)
276277
}
277-
msg += fmt.Sprintf("\n <href=%s://127.0.0.1:%d>%s://127.0.0.1:%d</>", scheme, port, scheme, port)
278+
applicationUrl := fmt.Sprintf("%s://127.0.0.1:%d", scheme, port)
279+
msg += fmt.Sprintf("\n <href=%s>%s</>", applicationUrl, applicationUrl)
278280
if proxyConf, err := proxy.Load(homeDir); err == nil {
279281
for _, domain := range proxyConf.GetDomains(projectDir) {
280282
msg += fmt.Sprintf("\n <href=%s://%s>%s://%s</>", scheme, domain, scheme, domain)
281283
}
284+
285+
domains := proxyConf.GetReachableDomains(projectDir)
286+
if len(domains) > 0 {
287+
applicationUrl = fmt.Sprintf("%s://%s", scheme, domains[0])
288+
}
289+
}
290+
291+
if c.Bool("open") {
292+
abstractOpenCmd(applicationUrl)
282293
}
283294

284295
select {

0 commit comments

Comments
 (0)