-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcmd_fmt.go
More file actions
58 lines (47 loc) · 1.8 KB
/
Copy pathcmd_fmt.go
File metadata and controls
58 lines (47 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
////////////////////////////////////////////////////////////////////////////
// Program: jsonfiddle
// Purpose: JSON Fiddling
// Authors: Tong Sun (c) 2017-2025, All rights reserved
////////////////////////////////////////////////////////////////////////////
package main
import (
"fmt"
"os"
"github.com/go-easygen/go-flags/clis"
)
// *** Sub-command: fmt ***
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
// The FmtCommand type defines all the configurable options from cli.
type FmtCommand struct {
Filei string `short:"i" long:"input" description:"the source to get json string from (mandatory)" required:"true"`
Fileo string `short:"o" long:"output" description:"the output, default to stdout" default:"-"`
Concise bool `short:"s" long:"concise" description:"Compact the top level array into concise array style"`
Unescape bool `short:"u" long:"unescape" description:"Unescape unicode of form \u003c to their literal characters"`
}
var fmtCommand FmtCommand
////////////////////////////////////////////////////////////////////////////
// Function definitions
func init() {
gfParser.AddCommand("fmt",
"Format json string",
`
`,
&fmtCommand)
}
func (x *FmtCommand) Execute(args []string) error {
fmt.Fprintf(os.Stderr, "Format json string\n")
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2025, Tong Sun\n\n")
clis.Setup("jsonfiddle::fmt", Opts.Verbose)
clis.Verbose(1, "Doing Fmt, with %+v, %+v", Opts, args)
// fmt.Println(x.Filei, x.Fileo, x.Concise, x.Unescape)
return x.Exec(args)
}
// // Exec implements the business logic of command `fmt`
// func (x *FmtCommand) Exec(args []string) error {
// // err := ...
// // clis.WarnOn("fmt::Exec", err)
// // or,
// // clis.AbortOn("fmt::Exec", err)
// return nil
// }