Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 400e161

Browse files
committed
Copy fixes.
1 parent 3974916 commit 400e161

File tree

11 files changed

+326
-310
lines changed

11 files changed

+326
-310
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
dist/
33
bin/
44
buildtools/*/*
5+
tests/src
6+
tests/target

.idea/workspace.xml

Lines changed: 49 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
)
88

99
const onlyOnce = "1"
10+
var onlyTwice = []string{"", ""}
1011

1112

1213
func init() {

cmd/funcs.go

Lines changed: 17 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,21 @@ func ProcessArgs(toolArgs *loadTools.TypeScribeArgs, cmd *cobra.Command, args []
2525
break
2626
}
2727

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+
}
4440
}
4541
}
42+
_ = Cmd.Runtime.SetArgs(args...)
4643

4744
state = toolArgs.ImportTools(&deploywp.GetHelpers)
4845
if state.IsNotOk() {
@@ -63,6 +60,8 @@ func cmdBuild(cmd *cobra.Command, args []string) {
6360
state := Cmd.State
6461

6562
for range onlyOnce {
63+
Cmd.Chdir = true // In this mode we always change directory to the JSON file.
64+
6665
state = ProcessArgs(Cmd, cmd, args)
6766
if state.IsNotOk() {
6867
state.PrintResponse()
@@ -77,6 +76,7 @@ func cmdBuild(cmd *cobra.Command, args []string) {
7776

7877
ux.PrintflnOk("Building website via deploywp.")
7978
state = Cmd.Run()
79+
8080
//dwp := deploywp.HelperLoadDeployWp(Cmd.JsonStruct.Json, Cmd.Runtime.GetArgs()...)
8181
//if dwp.State.IsNotOk() {
8282
// dwp.State.PrintResponse()
@@ -89,43 +89,12 @@ func cmdBuild(cmd *cobra.Command, args []string) {
8989
// //Cmd.State.Exit(1)
9090
// break
9191
//}
92-
//
93-
//ux.PrintflnBlue("\n%s\nFINISHED", Cmd.State.SprintResponse())
9492

9593
state.PrintResponse()
94+
ux.PrintflnBlue("\n# FINISHED")
9695
}
9796

9897
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-
//}
12998
}
13099

131100

@@ -231,42 +200,3 @@ func cmdRun(cmd *cobra.Command, args []string) {
231200

232201
Cmd.State = state
233202
}
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-
//}

cmd/load.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)