cli run/build/install more simples
This commit is contained in:
parent
8b50a6d8e0
commit
e222280345
4
main.go
4
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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user