Skip to content

Commit 289d184

Browse files
committed
code refactored
1 parent 796ef2c commit 289d184

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

cliTools/loadFlags.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cliTools
22

33
import (
44
"flag"
5+
"github.com/fatih/color"
6+
"go/build"
57
)
68

79
func LoadCMD(filepath string, modOrFile string) (string, string, string, string, *bool, bool, string, string, string) {
@@ -25,5 +27,17 @@ func LoadCMD(filepath string, modOrFile string) (string, string, string, string,
2527
arch := *archP
2628
command := *commandP
2729
modOrFile = *modOrFileP
30+
if init == true && name == "" {
31+
color.Red("Missing parameter: -name")
32+
} else if init == true {
33+
if arch == "" && os == "" {
34+
arch = build.Default.GOARCH
35+
os = build.Default.GOOS
36+
} else if arch == "" {
37+
arch = build.Default.GOARCH
38+
} else if os == "" {
39+
os = build.Default.GOOS
40+
}
41+
}
2842
return filepath, modOrFile, cnf, command, helpP, init, name, os, arch
2943
}

controllers/functions.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package controllers
22

33
import (
4-
"go/build"
54
"godemon/models"
65
)
76

@@ -13,14 +12,6 @@ func ProgramStarting(cnf *string, filepath string, modOrFile string, command str
1312
} else if *cnf == "deploy" {
1413
deploy(oso, arch, hOS)
1514
} else if init == true {
16-
if arch == "" && oso == "" {
17-
arch = build.Default.GOARCH
18-
oso = build.Default.GOOS
19-
} else if arch == "" {
20-
arch = build.Default.GOARCH
21-
} else if oso == "" {
22-
oso = build.Default.GOOS
23-
}
2415
initialize(name, arch, oso)
2516
} else if *help == true ||
2617
(*cnf == "" && filepath == "" && modOrFile == "" &&

0 commit comments

Comments
 (0)