Skip to content

Commit 31f4147

Browse files
update init command
1 parent 3631f1a commit 31f4147

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

cmd/init.go

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"gopkg.in/yaml.v3"
1010
"os"
1111
"path/filepath"
12+
"runtime"
1213
)
1314

1415
var InitCmd = &cobra.Command{
@@ -23,26 +24,36 @@ var InitCmd = &cobra.Command{
2324
}
2425

2526
var echoConfig map[string]any
27+
var configOs = runtime.GOOS
2628

27-
if app.InitCmdIsWindows {
28-
echoConfig = map[string]any{
29-
"tasks": []map[string]any{
30-
{
31-
"name": "echo",
32-
"executable": "cmd.exe",
33-
"args": []string{"/C", "echo hello world"},
34-
},
29+
var windowsConfig = map[string]any{
30+
"tasks": []map[string]any{
31+
{
32+
"name": "echo",
33+
"executable": "cmd.exe",
34+
"args": []string{"/C", "echo hello world"},
3535
},
36-
}
37-
} else {
38-
echoConfig = map[string]any{
39-
"tasks": []map[string]any{
40-
{
41-
"name": "echo",
42-
"executable": "echo",
43-
"args": []string{"hello", "world"},
44-
},
36+
},
37+
}
38+
39+
var linuxConfig = map[string]any{
40+
"tasks": []map[string]any{
41+
{
42+
"name": "echo",
43+
"executable": "echo",
44+
"args": []string{"hello", "world"},
4545
},
46+
},
47+
}
48+
49+
if app.InitCmdIsWindows {
50+
echoConfig = windowsConfig
51+
configOs = "windows"
52+
} else {
53+
if runtime.GOOS == "windows" {
54+
echoConfig = windowsConfig
55+
} else {
56+
echoConfig = linuxConfig
4657
}
4758
}
4859

@@ -77,7 +88,9 @@ var InitCmd = &cobra.Command{
7788
if err != nil {
7889
utils.SharedAppLogger.Fatal(err)
7990
}
80-
utils.SharedAppLogger.Info("Successfully generated quickstart.yaml", "path", outputFile)
91+
utils.SharedAppLogger.Info("os:", runtime.GOOS)
92+
utils.SharedAppLogger.Info("config file os type:", configOs)
93+
utils.SharedAppLogger.Info("Successfully generated quickstart.yaml at path:", outputFile)
8194
},
8295
}
8396

0 commit comments

Comments
 (0)