You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Root Object Name |`--root=RootObject`|`string`| Name for top-level object in JSON payload |`Root`|
38
38
| Package Name |`--package=api`|`string`| Name of package to generate types into. A nested package path is valid |`main`|
39
39
| Output File Name |`--output`|`string`| The name of the file that is generated. If a file is provided as input, will use matching name unless explicitly provided. The ".go" extension is not required and will be automatically appended. |`types.go`|
40
+
| Time Format |`--time=2006-01-02`|`string`| Time format to use while parsing strings for potential time.Time variables. View time.Time constants for possible defaults: https://pkg.go.dev/time#pkg-constants|`RFC3339`|
40
41
| Debug logging |`--debug`|`bool`| Will output debugging console logs. |`false`|
41
42
| Quiet |`--quiet`|`bool`| Will quiet fatal errors. |`false`|
42
43
| STDOUT |`--out`|`bool`| Instead of generating a Go file, will instead print the contents to STDOUT |`false`|
Copy file name to clipboardExpand all lines: cmd/generate.go
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ package cmd
3
3
import (
4
4
"fmt"
5
5
"log"
6
+
"time"
6
7
7
8
"github.com/alehechka/json2go/gen"
8
9
"github.com/urfave/cli/v2"
@@ -17,6 +18,7 @@ const (
17
18
debugFlag="debug"
18
19
quietFlag="quiet"
19
20
stdoutFlag="out"
21
+
timeFormatFlag="time"
20
22
)
21
23
22
24
vargenerateFlags= []cli.Flag{
@@ -49,6 +51,12 @@ var generateFlags = []cli.Flag{
49
51
The ".go" extension is not required and will be automatically appended.`,
50
52
Value: gen.DefaultOutputFile,
51
53
},
54
+
&cli.StringFlag{
55
+
Name: timeFormatFlag,
56
+
Aliases: []string{"t"},
57
+
Usage: "Time format to use while parsing strings for potential time.Time variables. View time.Time constants for possible defaults: https://pkg.go.dev/time#pkg-constants",
0 commit comments