diff --git a/cmd/generate.go b/cmd/generate.go index 5f0d2a4..62e2164 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -10,16 +10,17 @@ import ( ) const ( - urlFlag = "url" - fileFlag = "file" - rootFlag = "root" - packageFlag = "package" - outputFileFlag = "output" - debugFlag = "debug" - quietFlag = "quiet" - stdoutFlag = "out" - timeFormatFlag = "time" - omitEmptyFlag = "omitempty" + urlFlag = "url" + fileFlag = "file" + rootFlag = "root" + packageFlag = "package" + outputFileFlag = "output" + debugFlag = "debug" + quietFlag = "quiet" + stdoutFlag = "out" + timeFormatFlag = "time" + omitEmptyFlag = "omitempty" + alphabeticalFlag = "alphabetical" ) var generateFlags = []cli.Flag{ @@ -62,6 +63,11 @@ var generateFlags = []cli.Flag{ Name: omitEmptyFlag, Usage: "Appends the omitempty to all object variable tags.", }, + &cli.BoolFlag{ + Name: alphabeticalFlag, + Aliases: []string{"a", "alpha"}, + Usage: "Sorts all keys into alphabetical order before generation.", + }, &cli.BoolFlag{ Name: debugFlag, Usage: "Log debug messages.", @@ -93,6 +99,7 @@ func generateTypes(ctx *cli.Context) (err error) { OutputFileName: ctx.String(outputFileFlag), TimeFormat: ctx.String(timeFormatFlag), OmitEmpty: ctx.Bool(omitEmptyFlag), + Alphabetical: ctx.Bool(alphabeticalFlag), } if ctx.Bool(stdoutFlag) { diff --git a/gen/config.go b/gen/config.go index ebb8f3b..0643be3 100644 --- a/gen/config.go +++ b/gen/config.go @@ -20,6 +20,7 @@ type Config struct { OutputFileName string TimeFormat string OmitEmpty bool + Alphabetical bool } func (c *Config) toJensharedConfig() *jenshared.Config { @@ -39,6 +40,7 @@ func (c *Config) toJensharedConfig() *jenshared.Config { OutputDirectory: dir, TimeFormat: c.getTimeFormat(), OmitEmpty: c.OmitEmpty, + Alphabetical: c.Alphabetical, Debugger: c.Debugger, } }