From e2222803453701e9041a8af0db6e204a3aacafa1 Mon Sep 17 00:00:00 2001 From: alessio Date: Sun, 21 Aug 2016 09:37:56 +0200 Subject: [PATCH] cli run/build/install more simples --- main.go | 4 ++-- realize/config.go | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 99a2093..2fdb80f 100644 --- a/main.go +++ b/main.go @@ -87,8 +87,8 @@ func main() { &cli.StringFlag{Name: "name", Aliases: []string{"n"}, Usage: "Project name \t"}, &cli.StringFlag{Name: "base", Aliases: []string{"b"}, Value: wd(), Usage: "Project base path \t"}, &cli.BoolFlag{Name: "build", Value: false}, - &cli.BoolFlag{Name: "run", Value: true}, - &cli.BoolFlag{Name: "bin", Value: true}, + &cli.BoolFlag{Name: "run"}, + &cli.BoolFlag{Name: "bin"}, }, Action: func(p *cli.Context) error { y := r.New(p) diff --git a/realize/config.go b/realize/config.go index 378e9a7..b16803e 100644 --- a/realize/config.go +++ b/realize/config.go @@ -16,7 +16,8 @@ type Config struct { Projects []Project } -func projectName(params *cli.Context) string{ +// nameParam check the project name presence. If empty takes the working directory name +func nameParam(params *cli.Context) string{ var name string if params.String("name") == "" { name = params.String("base") @@ -26,6 +27,13 @@ func projectName(params *cli.Context) string{ return name } +func boolParam(b bool) bool{ + if b{ + return false + } + return true +} + // New method puts the cli params in the struct func New(params *cli.Context) *Config { return &Config{ @@ -33,11 +41,11 @@ func New(params *cli.Context) *Config { Version: AppVersion, Projects: []Project{ { - Name: projectName(params), + Name: nameParam(params), Path: params.String("base"), - Run: params.Bool("run"), Build: params.Bool("build"), - Bin: params.Bool("bin"), + Bin: boolParam(params.Bool("bin")), + Run: boolParam(params.Bool("run")), Watcher: Watcher{ Paths: watcherPaths, Ignore: watcherIgnores, @@ -113,11 +121,11 @@ func (h *Config) Add(params *cli.Context) error { err := h.Read() if err == nil { new := Project{ - Name: projectName(params), + Name: nameParam(params), Path: params.String("base"), - Run: params.Bool("run"), Build: params.Bool("build"), - Bin: params.Bool("bin"), + Bin: boolParam(params.Bool("bin")), + Run: boolParam(params.Bool("run")), Watcher: Watcher{ Paths: watcherPaths, Exts: watcherExts,