Skip to content

Commit

Permalink
Added append-port flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Krisztián Szabó authored and spf13 committed Dec 29, 2013
1 parent e5aa08f commit 5550c41
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import (

var serverPort int
var serverWatch bool
var serverAppend bool

func init() {
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port to run the server on")
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed")
serverCmd.Flags().BoolVarP(&serverAppend, "append-port", "", true, "append port to baseurl")
}

var serverCmd = &cobra.Command{
Expand All @@ -49,7 +51,11 @@ func server(cmd *cobra.Command, args []string) {
BaseUrl = "http://" + BaseUrl
}

Config.BaseUrl = strings.TrimSuffix(BaseUrl, "/") + ":" + strconv.Itoa(serverPort)
if serverAppend {
Config.BaseUrl = strings.TrimSuffix(BaseUrl, "/") + ":" + strconv.Itoa(serverPort)
} else {
Config.BaseUrl = strings.TrimSuffix(BaseUrl, "/")
}

build(serverWatch)

Expand Down

0 comments on commit 5550c41

Please sign in to comment.