print server address on start
This commit is contained in:
parent
6fe4d62a80
commit
2fd91f3464
21
app/main.go
21
app/main.go
|
@ -17,6 +17,7 @@ const (
|
||||||
Limit = 10000
|
Limit = 10000
|
||||||
Config = "r.config.yaml"
|
Config = "r.config.yaml"
|
||||||
Output = "r.output.log"
|
Output = "r.output.log"
|
||||||
|
Host = "Web server listening on localhost:5000"
|
||||||
)
|
)
|
||||||
|
|
||||||
var r realize
|
var r realize
|
||||||
|
@ -25,22 +26,22 @@ var R Realizer
|
||||||
// Realizer interface for wrap the cli, app and server functions
|
// Realizer interface for wrap the cli, app and server functions
|
||||||
type Realizer interface {
|
type Realizer interface {
|
||||||
Wdir() string
|
Wdir() string
|
||||||
Before() error
|
|
||||||
Red(string) string
|
Red(string) string
|
||||||
Blue(string) string
|
Blue(string) string
|
||||||
BlueS(string) string
|
BlueS(string) string
|
||||||
Handle(error) error
|
Handle(error) error
|
||||||
Serve(*cli.Context)
|
Serve(*cli.Context)
|
||||||
|
Before(*cli.Context) error
|
||||||
Fast(*cli.Context) error
|
Fast(*cli.Context) error
|
||||||
Run(p *cli.Context) error
|
Run(*cli.Context) error
|
||||||
Add(p *cli.Context) error
|
Add(*cli.Context) error
|
||||||
Remove(p *cli.Context) error
|
Remove(*cli.Context) error
|
||||||
List(p *cli.Context) error
|
List(*cli.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Realize struct contains the general app informations
|
// Realize struct contains the general app informations
|
||||||
type realize struct {
|
type realize struct {
|
||||||
Name, Description, Author, Email string
|
Name, Description, Author, Email, Host string
|
||||||
Version string
|
Version string
|
||||||
Limit uint64
|
Limit uint64
|
||||||
Blueprint c.Blueprint
|
Blueprint c.Blueprint
|
||||||
|
@ -55,6 +56,7 @@ func init() {
|
||||||
Name: Name,
|
Name: Name,
|
||||||
Version: Version,
|
Version: Version,
|
||||||
Description: Description,
|
Description: Description,
|
||||||
|
Host: Host,
|
||||||
Limit: Limit,
|
Limit: Limit,
|
||||||
Files: map[string]string{
|
Files: map[string]string{
|
||||||
"config": Config,
|
"config": Config,
|
||||||
|
@ -133,9 +135,14 @@ func (r *realize) List(p *cli.Context) error {
|
||||||
return r.Blueprint.List()
|
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.Blue(r.Name) + " - " + r.Blue(r.Version))
|
||||||
|
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")
|
fmt.Println(r.BlueS(r.Description) + "\n")
|
||||||
|
}
|
||||||
gopath := os.Getenv("GOPATH")
|
gopath := os.Getenv("GOPATH")
|
||||||
if gopath == "" {
|
if gopath == "" {
|
||||||
log.Fatal(r.Red("$GOPATH isn't set up properly"))
|
log.Fatal(r.Red("$GOPATH isn't set up properly"))
|
||||||
|
|
10
realize.go
10
realize.go
|
@ -36,7 +36,7 @@ func main() {
|
||||||
return app.Handle(app.Run(p))
|
return app.Handle(app.Run(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
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))
|
return app.Handle(app.Fast(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
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))
|
return app.Handle(app.Add(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
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))
|
return app.Handle(app.Remove(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
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))
|
return app.Handle(app.List(p))
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
return app.Before()
|
return app.Before(c)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (s *Server) Start() {
|
||||||
//e.GET("/ws", standard.WrapHandler(s.projects()))
|
//e.GET("/ws", standard.WrapHandler(s.projects()))
|
||||||
e.GET("/ws", standard.WrapHandler(s.projects()))
|
e.GET("/ws", standard.WrapHandler(s.projects()))
|
||||||
go e.Run(standard.New(":5000"))
|
go e.Run(standard.New(":5000"))
|
||||||
if(s.Open) {
|
if s.Open {
|
||||||
Open("http://localhost:5000")
|
Open("http://localhost:5000")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue