cli options for open the web panel in browser

This commit is contained in:
alessio 2016-10-17 11:44:45 +02:00
parent 53841e02bd
commit 6fe4d62a80
3 changed files with 7 additions and 1 deletions

View File

@ -105,6 +105,7 @@ func (r *realize) Wdir() string {
func (r *realize) Serve(p *cli.Context) {
if !p.Bool("no-server") {
r.Server.Open = p.Bool("open")
r.Server.Start()
}
}

View File

@ -30,6 +30,7 @@ func main() {
Usage: "Build and watch file changes",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "no-server", Usage: "Enable the web panel"},
&cli.BoolFlag{Name: "open", Usage: "Automatically opens the web panel"},
},
Action: func(p *cli.Context) error {
return app.Handle(app.Run(p))
@ -48,6 +49,7 @@ func main() {
&cli.BoolFlag{Name: "no-bin", Usage: "Disables the installation"},
&cli.BoolFlag{Name: "no-fmt", Usage: "Disables the fmt (go fmt)"},
&cli.BoolFlag{Name: "no-server", Usage: "Disables the web panel"},
&cli.BoolFlag{Name: "open", Usage: "Automatically opens the web panel"},
&cli.BoolFlag{Name: "test", Value: false, Usage: "Enables the tests"},
&cli.BoolFlag{Name: "config", Value: false, Usage: "Take the defined settings if exist a Configuration file."},
},

View File

@ -16,6 +16,7 @@ type Server struct {
Blueprint *c.Blueprint
Files map[string]string
Sync chan string
Open bool
}
func render(c echo.Context, path string, mime int) error {
@ -82,7 +83,9 @@ func (s *Server) Start() {
//e.GET("/ws", standard.WrapHandler(s.projects()))
e.GET("/ws", standard.WrapHandler(s.projects()))
go e.Run(standard.New(":5000"))
Open("http://localhost:5000")
if(s.Open) {
Open("http://localhost:5000")
}
}
// The WebSocket for projects list