-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmd_x2j.go
55 lines (44 loc) · 1.53 KB
/
cmd_x2j.go
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
////////////////////////////////////////////////////////////////////////////
// Program: jsonfiddle
// Purpose: JSON Fiddling
// Authors: Tong Sun (c) 2017-2023, All rights reserved
////////////////////////////////////////////////////////////////////////////
package main
import (
"fmt"
"os"
"github.com/go-easygen/go-flags/clis"
)
// *** Sub-command: x2j ***
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
// The X2jCommand type defines all the configurable options from cli.
type X2jCommand struct {
Filei string `short:"i" long:"input" description:"the source of the input JSON (mandatory)" required:"true"`
Fileo string `short:"o" long:"output" description:"the output, default to stdout" default:"-"`
}
var x2jCommand X2jCommand
////////////////////////////////////////////////////////////////////////////
// Function definitions
func init() {
gfParser.AddCommand("x2j",
"XML to JSON",
"",
&x2jCommand)
}
func (x *X2jCommand) Execute(args []string) error {
fmt.Fprintf(os.Stderr, "XML to JSON\n")
// fmt.Fprintf(os.Stderr, "Copyright (C) 2017-2023, Tong Sun\n\n")
clis.Setup("jsonfiddle::x2j", opts.Verbose)
clis.Verbose(1, "Doing X2j, with %+v, %+v", opts, args)
// fmt.Println(x.Filei, x.Fileo)
return x.Exec(args)
}
// // Exec implements the business logic of command `x2j`
// func (x *X2jCommand) Exec(args []string) error {
// // err := ...
// // clis.WarnOn("x2j::Exec", err)
// // or,
// // clis.AbortOn("x2j::Exec", err)
// return nil
// }