Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Mar 18, 2021
1 parent 5cf3bb1 commit f1ee0ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
26 changes: 3 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,34 +332,14 @@ func startTower() {
app = NewApp(c.Conf.App.MainFile, c.Conf.App.Port, c.Conf.App.BuildDir, c.Conf.App.PortParamName)
}
app.OfflineMode = c.Conf.Offline
app.DisabledLogRequest = c.Conf.LogRequest == false
app.DisabledLogRequest = !c.Conf.LogRequest
app.PkgMirrors = c.Conf.App.PkgMirrors
app.Env = append(app.Env, c.Conf.App.Env...)
if len(c.Conf.App.RunParams) > 0 {
delim := ` `
param := c.Conf.App.RunParams
//:<分割符>:<参数>
if param[0] == ':' {
param = strings.TrimPrefix(param, `:`)
if pos := strings.Index(param, `:`); pos > 0 {
delim = param[0:pos]
param = param[pos+1:]
}
}
app.RunParams = strings.Split(param, delim)
app.RunParams = parseParams(c.Conf.App.RunParams)
}
if len(c.Conf.App.BuildParams) > 0 {
delim := ` `
param := c.Conf.App.BuildParams
//:<分割符>:<参数>
if param[0] == ':' {
param = strings.TrimPrefix(param, `:`)
if pos := strings.Index(param, `:`); pos > 0 {
delim = param[0:pos]
param = param[pos+1:]
}
}
app.BuildParams = strings.Split(param, delim)
app.BuildParams = parseParams(c.Conf.App.BuildParams)
}
watchedDir := app.Root
if !allowBuild {
Expand Down
18 changes: 18 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"net"
"os"
"path/filepath"
"strings"
"time"

"github.com/webx-top/com"
)

var (
Expand Down Expand Up @@ -103,3 +106,18 @@ func quickSort(arr []int64, start, end int) {
}
}
}

func parseParams(param string) []string {
if param[0] != ':' {
return com.ParseArgs(param)
}

//:<分割符>:<参数>
delim := ` `
param = strings.TrimPrefix(param, `:`)
if pos := strings.Index(param, `:`); pos > 0 {
delim = param[0:pos]
param = param[pos+1:]
}
return strings.Split(param, delim)
}

0 comments on commit f1ee0ff

Please sign in to comment.