1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

Added default base image + New layout for displaying options

This commit is contained in:
Faissal Elamraoui 2016-12-23 11:53:02 +01:00
parent 4ea1715df6
commit 040b160ecd
2 changed files with 5 additions and 12 deletions

11
bee.go
View File

@ -99,12 +99,7 @@ func (c *Command) Options() map[string]string {
c.Flag.VisitAll(func(f *flag.Flag) { c.Flag.VisitAll(func(f *flag.Flag) {
defaultVal := f.DefValue defaultVal := f.DefValue
if len(defaultVal) > 0 { if len(defaultVal) > 0 {
if strings.Contains(defaultVal, ":") { options[f.Name+"="+defaultVal] = f.Usage
// Truncate the flag's default value by appending '...' at the end
options[f.Name+"="+strings.Split(defaultVal, ":")[0]+":..."] = f.Usage
} else {
options[f.Name+"="+defaultVal] = f.Usage
}
} else { } else {
options[f.Name] = f.Usage options[f.Name] = f.Usage
} }
@ -210,7 +205,9 @@ Use {{"bee help [topic]" | bold}} for more information about that topic.
var helpTemplate = `{{"USAGE" | headline}} var helpTemplate = `{{"USAGE" | headline}}
{{.UsageLine | printf "bee %s" | bold}} {{.UsageLine | printf "bee %s" | bold}}
{{if .Options}}{{endline}}{{"OPTIONS" | headline}}{{range $k,$v := .Options}} {{if .Options}}{{endline}}{{"OPTIONS" | headline}}{{range $k,$v := .Options}}
{{$k | printf "-%-12s" | bold}} {{$v}}{{end}}{{endline}}{{end}} {{$k | printf "-%s" | bold}}
{{$v}}
{{end}}{{end}}
{{"DESCRIPTION" | headline}} {{"DESCRIPTION" | headline}}
{{tmpltostr .Long . | trim}} {{tmpltostr .Long . | trim}}
` `

View File

@ -74,7 +74,7 @@ var (
func init() { func init() {
fs := flag.NewFlagSet("dockerize", flag.ContinueOnError) fs := flag.NewFlagSet("dockerize", flag.ContinueOnError)
fs.StringVar(&baseImage, "image", "", "Sets the base image of the Docker container.") fs.StringVar(&baseImage, "image", "library/golang", "Set the base image of the Docker container.")
fs.StringVar(&expose, "expose", "8080", "Port(s) to expose in the Docker container.") fs.StringVar(&expose, "expose", "8080", "Port(s) to expose in the Docker container.")
cmdDockerize.Flag = *fs cmdDockerize.Flag = *fs
} }
@ -90,10 +90,6 @@ func dockerizeApp(cmd *Command, args []string) int {
dir, err := filepath.Abs(".") dir, err := filepath.Abs(".")
MustCheck(err) MustCheck(err)
if len(baseImage) == 0 {
baseImage = "library/golang:latest"
}
appdir := strings.Replace(dir, gopath, "", 1) appdir := strings.Replace(dir, gopath, "", 1)
// In case of multiple ports to expose inside the container, // In case of multiple ports to expose inside the container,