@@ -25,24 +25,21 @@ func ProcessArgs(toolArgs *loadTools.TypeScribeArgs, cmd *cobra.Command, args []
25
25
break
26
26
}
27
27
28
- ext := ""
29
- if len (args ) >= 1 {
30
- ext := filepath .Ext (args [0 ])
31
- if ext == ".json" {
32
- toolArgs .Json .Filename = args [0 ]
33
- } else if ext == ".tmpl" {
34
- toolArgs .Template .Filename = args [0 ]
35
- }
36
- }
37
-
38
- if len (args ) >= 2 {
39
- ext = filepath .Ext (args [1 ])
40
- if ext == ".json" {
41
- toolArgs .Json .Filename = args [1 ]
42
- } else if ext == ".tmpl" {
43
- toolArgs .Template .Filename = args [1 ]
28
+ for range onlyTwice {
29
+ if len (args ) >= 1 {
30
+ ext := filepath .Ext (args [0 ])
31
+ if ext == ".json" {
32
+ toolArgs .Json .Filename = args [0 ]
33
+ args = args [1 :]
34
+ } else if ext == ".tmpl" {
35
+ toolArgs .Template .Filename = args [0 ]
36
+ args = args [1 :]
37
+ } else {
38
+ break
39
+ }
44
40
}
45
41
}
42
+ _ = Cmd .Runtime .SetArgs (args ... )
46
43
47
44
state = toolArgs .ImportTools (& deploywp .GetHelpers )
48
45
if state .IsNotOk () {
@@ -63,6 +60,8 @@ func cmdBuild(cmd *cobra.Command, args []string) {
63
60
state := Cmd .State
64
61
65
62
for range onlyOnce {
63
+ Cmd .Chdir = true // In this mode we always change directory to the JSON file.
64
+
66
65
state = ProcessArgs (Cmd , cmd , args )
67
66
if state .IsNotOk () {
68
67
state .PrintResponse ()
@@ -77,6 +76,7 @@ func cmdBuild(cmd *cobra.Command, args []string) {
77
76
78
77
ux .PrintflnOk ("Building website via deploywp." )
79
78
state = Cmd .Run ()
79
+
80
80
//dwp := deploywp.HelperLoadDeployWp(Cmd.JsonStruct.Json, Cmd.Runtime.GetArgs()...)
81
81
//if dwp.State.IsNotOk() {
82
82
// dwp.State.PrintResponse()
@@ -89,43 +89,12 @@ func cmdBuild(cmd *cobra.Command, args []string) {
89
89
// //Cmd.State.Exit(1)
90
90
// break
91
91
//}
92
- //
93
- //ux.PrintflnBlue("\n%s\nFINISHED", Cmd.State.SprintResponse())
94
92
95
93
state .PrintResponse ()
94
+ ux .PrintflnBlue ("\n # FINISHED" )
96
95
}
97
96
98
97
Cmd .State = state
99
-
100
- //for range onlyOnce {
101
- // Cmd.State = tmpl.Load()
102
- // if Cmd.State.IsNotOk() {
103
- // Cmd.State.PrintResponse()
104
- // break
105
- // }
106
- //
107
- // ux.PrintflnOk("Running build.")
108
- // Cmd.State = tmpl.Run()
109
- // Cmd.State.PrintResponse()
110
- //
111
- // //dwp := deploywp.TypeDeployWp{}
112
- // //dwp := deploywp.HelperLoadDeployWp(tmpl.JsonStruct.Json, tmpl.Exec.GetArgs()...)
113
- // //if dwp.State.IsNotOk() {
114
- // // dwp.State.PrintResponse()
115
- // // break
116
- // //}
117
- // //
118
- // //dwp.Exec = tmpl.JsonStruct.Exec
119
- // //Cmd.State = dwp.Run()
120
- // //
121
- // //if Cmd.State.IsNotOk() {
122
- // // Cmd.State.SetExitCode(1)
123
- // // //Cmd.State.Exit(1)
124
- // // break
125
- // //}
126
- // //
127
- // //fmt.Printf("\n%s\nFINISHED\n", Cmd.State.SprintResponse())
128
- //}
129
98
}
130
99
131
100
@@ -231,42 +200,3 @@ func cmdRun(cmd *cobra.Command, args []string) {
231
200
232
201
Cmd .State = state
233
202
}
234
-
235
-
236
- //func ProcessArgs(cmd *cobra.Command, args []string) *loadTools.ArgTemplate {
237
- // var tmpl *loadTools.ArgTemplate
238
- // // tmpl := loadTools.NewArgTemplate()
239
- //
240
- // for range onlyOnce {
241
- // tmpl = Cmd
242
- //
243
- // _ = tmpl.Exec.SetArgs(cmd.Use)
244
- // _ = tmpl.Exec.AddArgs(args...)
245
- //
246
- // ext := ""
247
- // if len(args) >= 1 {
248
- // ext := filepath.Ext(args[0])
249
- // if ext == ".json" {
250
- // tmpl.Json.Name = args[0]
251
- // } else if ext == ".tmpl" {
252
- // tmpl.Template.Name = args[0]
253
- // }
254
- // }
255
- //
256
- // if len(args) >= 2 {
257
- // ext = filepath.Ext(args[1])
258
- // if ext == ".json" {
259
- // tmpl.Json.Name = args[1]
260
- // } else if ext == ".tmpl" {
261
- // tmpl.Template.Name = args[1]
262
- // }
263
- // }
264
- //
265
- // tmpl.ValidateArgs()
266
- // if tmpl.State.IsNotOk() {
267
- // break
268
- // }
269
- // }
270
- //
271
- // return tmpl
272
- //}
0 commit comments