diff --git a/pkg/functions/options.go b/pkg/functions/options.go index ae46d6dc..3a341a43 100644 --- a/pkg/functions/options.go +++ b/pkg/functions/options.go @@ -42,3 +42,9 @@ func SetPrefix(suffix string) func(*GrammarOption) { o.Prefix = suffix } } + +func SetPropOrder(order string) func(*GrammarOption) { + return func(o *GrammarOption) { + o.PropOrder = order + } +} diff --git a/pkg/functions/parse.go b/pkg/functions/parse.go index 146b80e1..a9eef658 100644 --- a/pkg/functions/parse.go +++ b/pkg/functions/parse.go @@ -32,6 +32,11 @@ type GrammarConfig struct { // ExpectStringsAfterJSON enables mixed string suffix ExpectStringsAfterJSON bool `yaml:"expect_strings_after_json"` + + // PropOrder selects what order to print properties + // for instance name,arguments will make print { "name": "foo", "arguments": { "bar": "baz" } } + // instead of { "arguments": { "bar": "baz" }, "name": "foo" } + PropOrder string `yaml:"properties_order"` } // FunctionsConfig is the configuration for the tool/function call. @@ -104,6 +109,8 @@ func (g GrammarConfig) Options() []func(o *GrammarOption) { if g.ExpectStringsAfterJSON { opts = append(opts, ExpectStringsAfterJSON) } + + opts = append(opts, SetPropOrder(g.PropOrder)) return opts }