Skip to content

Commit 3368f2b

Browse files
committed
- [#] apply new GoFlags template
1 parent 26f1343 commit 3368f2b

7 files changed

+94
-59
lines changed

cmd_esc.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ type EscCommand struct {
2626

2727
var escCommand EscCommand
2828

29+
////////////////////////////////////////////////////////////////////////////
30+
// Function definitions
31+
2932
func init() {
30-
parser.AddCommand("esc",
33+
gfParser.AddCommand("esc",
3134
"Escape json string",
3235
"",
3336
&escCommand)
@@ -38,15 +41,15 @@ func (x *EscCommand) Execute(args []string) error {
3841
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
3942
clis.Setup("jsonfiddle::esc", opts.Verbose)
4043
clis.Verbose(1, "Doing Esc, with %+v, %+v", opts, args)
41-
// fmt.Println(x.Filei, x.Fileo)
44+
// fmt.Println(x.Filei, x.Fileo)
4245
return x.Exec(args)
4346
}
4447

45-
// Exec implements the business logic of command `esc`
48+
// // Exec implements the business logic of command `esc`
4649
// func (x *EscCommand) Exec(args []string) error {
4750
// // err := ...
48-
// // clis.WarnOn("Esc, Exec", err)
51+
// // clis.WarnOn("esc::Exec", err)
4952
// // or,
50-
// // clis.AbortOn("Esc, Exec", err)
53+
// // clis.AbortOn("esc::Exec", err)
5154
// return nil
5255
// }

cmd_fmt.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ type FmtCommand struct {
2626

2727
var fmtCommand FmtCommand
2828

29+
////////////////////////////////////////////////////////////////////////////
30+
// Function definitions
31+
2932
func init() {
30-
parser.AddCommand("fmt",
33+
gfParser.AddCommand("fmt",
3134
"Format json string",
3235
"",
3336
&fmtCommand)
@@ -38,15 +41,15 @@ func (x *FmtCommand) Execute(args []string) error {
3841
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
3942
clis.Setup("jsonfiddle::fmt", opts.Verbose)
4043
clis.Verbose(1, "Doing Fmt, with %+v, %+v", opts, args)
41-
// fmt.Println(x.Filei, x.Fileo)
44+
// fmt.Println(x.Filei, x.Fileo)
4245
return x.Exec(args)
4346
}
4447

45-
// Exec implements the business logic of command `fmt`
48+
// // Exec implements the business logic of command `fmt`
4649
// func (x *FmtCommand) Exec(args []string) error {
4750
// // err := ...
48-
// // clis.WarnOn("Fmt, Exec", err)
51+
// // clis.WarnOn("fmt::Exec", err)
4952
// // or,
50-
// // clis.AbortOn("Fmt, Exec", err)
53+
// // clis.AbortOn("fmt::Exec", err)
5154
// return nil
5255
// }

cmd_j2s.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ type J2sCommand struct {
3030

3131
var j2sCommand J2sCommand
3232

33+
////////////////////////////////////////////////////////////////////////////
34+
// Function definitions
35+
3336
func init() {
34-
parser.AddCommand("j2s",
37+
gfParser.AddCommand("j2s",
3538
"JSON to struct",
3639
"JSON convert to Go struct",
3740
&j2sCommand)
@@ -42,15 +45,15 @@ func (x *J2sCommand) Execute(args []string) error {
4245
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
4346
clis.Setup("jsonfiddle::j2s", opts.Verbose)
4447
clis.Verbose(1, "Doing J2s, with %+v, %+v", opts, args)
45-
// fmt.Println(x.FmtType, x.Filei, x.Fileo, x.Name, x.Pkg, x.SubStruct)
48+
// fmt.Println(x.FmtType, x.Filei, x.Fileo, x.Name, x.Pkg, x.SubStruct)
4649
return x.Exec(args)
4750
}
4851

49-
// Exec implements the business logic of command `j2s`
52+
// // Exec implements the business logic of command `j2s`
5053
// func (x *J2sCommand) Exec(args []string) error {
5154
// // err := ...
52-
// // clis.WarnOn("J2s, Exec", err)
55+
// // clis.WarnOn("j2s::Exec", err)
5356
// // or,
54-
// // clis.AbortOn("J2s, Exec", err)
57+
// // clis.AbortOn("j2s::Exec", err)
5558
// return nil
5659
// }

cmd_sort.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ type SortCommand struct {
2626

2727
var sortCommand SortCommand
2828

29+
////////////////////////////////////////////////////////////////////////////
30+
// Function definitions
31+
2932
func init() {
30-
parser.AddCommand("sort",
33+
gfParser.AddCommand("sort",
3134
"Sort json fields recursively",
3235
"",
3336
&sortCommand)
@@ -38,15 +41,15 @@ func (x *SortCommand) Execute(args []string) error {
3841
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
3942
clis.Setup("jsonfiddle::sort", opts.Verbose)
4043
clis.Verbose(1, "Doing Sort, with %+v, %+v", opts, args)
41-
// fmt.Println(x.Filei, x.Fileo)
44+
// fmt.Println(x.Filei, x.Fileo)
4245
return x.Exec(args)
4346
}
4447

45-
// Exec implements the business logic of command `sort`
48+
// // Exec implements the business logic of command `sort`
4649
// func (x *SortCommand) Exec(args []string) error {
4750
// // err := ...
48-
// // clis.WarnOn("Sort, Exec", err)
51+
// // clis.WarnOn("sort::Exec", err)
4952
// // or,
50-
// // clis.AbortOn("Sort, Exec", err)
53+
// // clis.AbortOn("sort::Exec", err)
5154
// return nil
5255
// }

cmd_x2j.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ type X2jCommand struct {
2626

2727
var x2jCommand X2jCommand
2828

29+
////////////////////////////////////////////////////////////////////////////
30+
// Function definitions
31+
2932
func init() {
30-
parser.AddCommand("x2j",
33+
gfParser.AddCommand("x2j",
3134
"XML to JSON",
3235
"",
3336
&x2jCommand)
@@ -38,15 +41,15 @@ func (x *X2jCommand) Execute(args []string) error {
3841
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
3942
clis.Setup("jsonfiddle::x2j", opts.Verbose)
4043
clis.Verbose(1, "Doing X2j, with %+v, %+v", opts, args)
41-
// fmt.Println(x.Filei, x.Fileo)
44+
// fmt.Println(x.Filei, x.Fileo)
4245
return x.Exec(args)
4346
}
4447

45-
// Exec implements the business logic of command `x2j`
48+
// // Exec implements the business logic of command `x2j`
4649
// func (x *X2jCommand) Exec(args []string) error {
4750
// // err := ...
48-
// // clis.WarnOn("X2j, Exec", err)
51+
// // clis.WarnOn("x2j::Exec", err)
4952
// // or,
50-
// // clis.AbortOn("X2j, Exec", err)
53+
// // clis.AbortOn("x2j::Exec", err)
5154
// return nil
5255
// }

jsonfiddle_cliDef.go

+47-28
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,31 @@ import (
3434
// opts optsT
3535
// )
3636
//
37-
// var parser = flags.NewParser(&opts, flags.Default)
37+
// var gfParser = flags.NewParser(&opts, flags.Default)
3838

3939
////////////////////////////////////////////////////////////////////////////
4040
// Function definitions
4141

42+
//==========================================================================
4243
// Function main
4344
// func main() {
4445
// opts.Version = showVersion
4546
// opts.Verbflg = func() {
4647
// opts.Verbose++
4748
// }
4849
//
49-
// if _, err := parser.Parse(); err != nil {
50+
// if _, err := gfParser.Parse(); err != nil {
5051
// fmt.Println()
51-
// parser.WriteHelp(os.Stdout)
52+
// gfParser.WriteHelp(os.Stdout)
5253
// os.Exit(1)
5354
// }
5455
// fmt.Println()
5556
// //DoJsonfiddle()
5657
// }
5758
//
59+
// //==========================================================================
60+
// // support functions
61+
//
5862
// func showVersion() {
5963
// fmt.Fprintf(os.Stderr, "jsonfiddle - JSON Fiddling, version %s\n", version)
6064
// fmt.Fprintf(os.Stderr, "Built on %s\n", date)
@@ -114,8 +118,11 @@ type optsT struct {
114118
//
115119
// var escCommand EscCommand
116120
//
121+
// ////////////////////////////////////////////////////////////////////////////
122+
// // Function definitions
123+
//
117124
// func init() {
118-
// parser.AddCommand("esc",
125+
// gfParser.AddCommand("esc",
119126
// "Escape json string",
120127
// "",
121128
// &escCommand)
@@ -126,16 +133,16 @@ type optsT struct {
126133
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
127134
// clis.Setup("jsonfiddle::esc", opts.Verbose)
128135
// clis.Verbose(1, "Doing Esc, with %+v, %+v", opts, args)
129-
// fmt.Println(x.Filei, x.Fileo)
136+
// // fmt.Println(x.Filei, x.Fileo)
130137
// return x.Exec(args)
131138
// }
132139
//
133-
// Exec implements the business logic of command `esc`
140+
// // Exec implements the business logic of command `esc`
134141
// func (x *EscCommand) Exec(args []string) error {
135142
// // err := ...
136-
// // clis.WarnOn("Esc, Exec", err)
143+
// // clis.WarnOn("esc::Exec", err)
137144
// // or,
138-
// // clis.AbortOn("Esc, Exec", err)
145+
// // clis.AbortOn("esc::Exec", err)
139146
// return nil
140147
// }
141148
// Template for "esc" CLI handling ends here
@@ -170,8 +177,11 @@ type optsT struct {
170177
//
171178
// var fmtCommand FmtCommand
172179
//
180+
// ////////////////////////////////////////////////////////////////////////////
181+
// // Function definitions
182+
//
173183
// func init() {
174-
// parser.AddCommand("fmt",
184+
// gfParser.AddCommand("fmt",
175185
// "Format json string",
176186
// "",
177187
// &fmtCommand)
@@ -182,16 +192,16 @@ type optsT struct {
182192
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
183193
// clis.Setup("jsonfiddle::fmt", opts.Verbose)
184194
// clis.Verbose(1, "Doing Fmt, with %+v, %+v", opts, args)
185-
// fmt.Println(x.Filei, x.Fileo)
195+
// // fmt.Println(x.Filei, x.Fileo)
186196
// return x.Exec(args)
187197
// }
188198
//
189-
// Exec implements the business logic of command `fmt`
199+
// // Exec implements the business logic of command `fmt`
190200
// func (x *FmtCommand) Exec(args []string) error {
191201
// // err := ...
192-
// // clis.WarnOn("Fmt, Exec", err)
202+
// // clis.WarnOn("fmt::Exec", err)
193203
// // or,
194-
// // clis.AbortOn("Fmt, Exec", err)
204+
// // clis.AbortOn("fmt::Exec", err)
195205
// return nil
196206
// }
197207
// Template for "fmt" CLI handling ends here
@@ -226,8 +236,11 @@ type optsT struct {
226236
//
227237
// var sortCommand SortCommand
228238
//
239+
// ////////////////////////////////////////////////////////////////////////////
240+
// // Function definitions
241+
//
229242
// func init() {
230-
// parser.AddCommand("sort",
243+
// gfParser.AddCommand("sort",
231244
// "Sort json fields recursively",
232245
// "",
233246
// &sortCommand)
@@ -238,16 +251,16 @@ type optsT struct {
238251
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
239252
// clis.Setup("jsonfiddle::sort", opts.Verbose)
240253
// clis.Verbose(1, "Doing Sort, with %+v, %+v", opts, args)
241-
// fmt.Println(x.Filei, x.Fileo)
254+
// // fmt.Println(x.Filei, x.Fileo)
242255
// return x.Exec(args)
243256
// }
244257
//
245-
// Exec implements the business logic of command `sort`
258+
// // Exec implements the business logic of command `sort`
246259
// func (x *SortCommand) Exec(args []string) error {
247260
// // err := ...
248-
// // clis.WarnOn("Sort, Exec", err)
261+
// // clis.WarnOn("sort::Exec", err)
249262
// // or,
250-
// // clis.AbortOn("Sort, Exec", err)
263+
// // clis.AbortOn("sort::Exec", err)
251264
// return nil
252265
// }
253266
// Template for "sort" CLI handling ends here
@@ -286,8 +299,11 @@ type optsT struct {
286299
//
287300
// var j2sCommand J2sCommand
288301
//
302+
// ////////////////////////////////////////////////////////////////////////////
303+
// // Function definitions
304+
//
289305
// func init() {
290-
// parser.AddCommand("j2s",
306+
// gfParser.AddCommand("j2s",
291307
// "JSON to struct",
292308
// "JSON convert to Go struct",
293309
// &j2sCommand)
@@ -298,16 +314,16 @@ type optsT struct {
298314
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
299315
// clis.Setup("jsonfiddle::j2s", opts.Verbose)
300316
// clis.Verbose(1, "Doing J2s, with %+v, %+v", opts, args)
301-
// fmt.Println(x.FmtType, x.Filei, x.Fileo, x.Name, x.Pkg, x.SubStruct)
317+
// // fmt.Println(x.FmtType, x.Filei, x.Fileo, x.Name, x.Pkg, x.SubStruct)
302318
// return x.Exec(args)
303319
// }
304320
//
305-
// Exec implements the business logic of command `j2s`
321+
// // Exec implements the business logic of command `j2s`
306322
// func (x *J2sCommand) Exec(args []string) error {
307323
// // err := ...
308-
// // clis.WarnOn("J2s, Exec", err)
324+
// // clis.WarnOn("j2s::Exec", err)
309325
// // or,
310-
// // clis.AbortOn("J2s, Exec", err)
326+
// // clis.AbortOn("j2s::Exec", err)
311327
// return nil
312328
// }
313329
// Template for "j2s" CLI handling ends here
@@ -342,8 +358,11 @@ type optsT struct {
342358
//
343359
// var x2jCommand X2jCommand
344360
//
361+
// ////////////////////////////////////////////////////////////////////////////
362+
// // Function definitions
363+
//
345364
// func init() {
346-
// parser.AddCommand("x2j",
365+
// gfParser.AddCommand("x2j",
347366
// "XML to JSON",
348367
// "",
349368
// &x2jCommand)
@@ -354,16 +373,16 @@ type optsT struct {
354373
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
355374
// clis.Setup("jsonfiddle::x2j", opts.Verbose)
356375
// clis.Verbose(1, "Doing X2j, with %+v, %+v", opts, args)
357-
// fmt.Println(x.Filei, x.Fileo)
376+
// // fmt.Println(x.Filei, x.Fileo)
358377
// return x.Exec(args)
359378
// }
360379
//
361-
// Exec implements the business logic of command `x2j`
380+
// // Exec implements the business logic of command `x2j`
362381
// func (x *X2jCommand) Exec(args []string) error {
363382
// // err := ...
364-
// // clis.WarnOn("X2j, Exec", err)
383+
// // clis.WarnOn("x2j::Exec", err)
365384
// // or,
366-
// // clis.AbortOn("X2j, Exec", err)
385+
// // clis.AbortOn("x2j::Exec", err)
367386
// return nil
368387
// }
369388
// Template for "x2j" CLI handling ends here

0 commit comments

Comments
 (0)