diff --git a/app/main.go b/app/main.go index 9edfa4f..df079ca 100644 --- a/app/main.go +++ b/app/main.go @@ -17,6 +17,7 @@ const ( Limit = 10000 Config = "r.config.yaml" Output = "r.output.log" + Host = "Web server listening on localhost:5000" ) var r realize @@ -25,28 +26,28 @@ var R Realizer // Realizer interface for wrap the cli, app and server functions type Realizer interface { Wdir() string - Before() error Red(string) string Blue(string) string BlueS(string) string Handle(error) error Serve(*cli.Context) + Before(*cli.Context) error Fast(*cli.Context) error - Run(p *cli.Context) error - Add(p *cli.Context) error - Remove(p *cli.Context) error - List(p *cli.Context) error + Run(*cli.Context) error + Add(*cli.Context) error + Remove(*cli.Context) error + List(*cli.Context) error } // Realize struct contains the general app informations type realize struct { - Name, Description, Author, Email string - Version string - Limit uint64 - Blueprint c.Blueprint - Server s.Server - Files map[string]string - Sync chan string + Name, Description, Author, Email, Host string + Version string + Limit uint64 + Blueprint c.Blueprint + Server s.Server + Files map[string]string + Sync chan string } // Application initialization @@ -55,6 +56,7 @@ func init() { Name: Name, Version: Version, Description: Description, + Host: Host, Limit: Limit, Files: map[string]string{ "config": Config, @@ -133,9 +135,14 @@ func (r *realize) List(p *cli.Context) error { return r.Blueprint.List() } -func (r *realize) Before() error { +func (r *realize) Before(p *cli.Context) error { fmt.Println(r.Blue(r.Name) + " - " + r.Blue(r.Version)) - fmt.Println(r.BlueS(r.Description) + "\n") + if !p.Bool("no-server") { + fmt.Println(r.BlueS(r.Description)) + fmt.Println(r.Red(r.Host) + "\n") + } else { + fmt.Println(r.BlueS(r.Description) + "\n") + } gopath := os.Getenv("GOPATH") if gopath == "" { log.Fatal(r.Red("$GOPATH isn't set up properly")) diff --git a/realize.go b/realize.go index 946cf65..3ffd355 100644 --- a/realize.go +++ b/realize.go @@ -36,7 +36,7 @@ func main() { return app.Handle(app.Run(p)) }, Before: func(c *cli.Context) error { - return app.Before() + return app.Before(c) }, }, { @@ -57,7 +57,7 @@ func main() { return app.Handle(app.Fast(p)) }, Before: func(c *cli.Context) error { - return app.Before() + return app.Before(c) }, }, { @@ -78,7 +78,7 @@ func main() { return app.Handle(app.Add(p)) }, Before: func(c *cli.Context) error { - return app.Before() + return app.Before(c) }, }, { @@ -93,7 +93,7 @@ func main() { return app.Handle(app.Remove(p)) }, Before: func(c *cli.Context) error { - return app.Before() + return app.Before(c) }, }, { @@ -105,7 +105,7 @@ func main() { return app.Handle(app.List(p)) }, Before: func(c *cli.Context) error { - return app.Before() + return app.Before(c) }, }, }, diff --git a/server/main.go b/server/main.go index dd30e60..af6ca6a 100644 --- a/server/main.go +++ b/server/main.go @@ -16,7 +16,7 @@ type Server struct { Blueprint *c.Blueprint Files map[string]string Sync chan string - Open bool + Open bool } func render(c echo.Context, path string, mime int) error { @@ -83,7 +83,7 @@ func (s *Server) Start() { //e.GET("/ws", standard.WrapHandler(s.projects())) e.GET("/ws", standard.WrapHandler(s.projects())) go e.Run(standard.New(":5000")) - if(s.Open) { + if s.Open { Open("http://localhost:5000") } }