diff --git a/cmd/enbas-cli-generators/schema.go b/cmd/enbas-cli-generators/schema.go index a444590..eb288e5 100644 --- a/cmd/enbas-cli-generators/schema.go +++ b/cmd/enbas-cli-generators/schema.go @@ -53,13 +53,19 @@ func (e enbasCLISchemaFlagMap) getDescription(name string) string { } type enbasCLISchemaCommand struct { - UsePrinter bool `json:"usePrinter"` - UseConfig bool `json:"useConfig"` - Flags []enbasCLISchemaFlagReference `json:"flags"` - Summary string `json:"summary"` + AdditionalFields []enbasCLISchemaAdditionalFields `json:"additionalFields"` + Flags []enbasCLISchemaFlagReference `json:"flags"` + Summary string `json:"summary"` + UseConfig bool `json:"useConfig"` + UsePrinter bool `json:"usePrinter"` } type enbasCLISchemaFlagReference struct { Flag string `json:"flag"` Default string `json:"default"` } + +type enbasCLISchemaAdditionalFields struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/cmd/enbas-cli-generators/templates.go b/cmd/enbas-cli-generators/templates.go index 5e5de2b..9b65f20 100644 --- a/cmd/enbas-cli-generators/templates.go +++ b/cmd/enbas-cli-generators/templates.go @@ -18,6 +18,10 @@ type {{ $struct_name }} struct { {{ print "" }} {{ $flag.Flag }} {{ getFlagType $flag.Flag }} {{- end -}} + {{- range $field := $command.AdditionalFields -}} + {{ print "" }} + {{ $field.Name }} {{ $field.Type }} + {{- end -}} {{ print "" }} } @@ -28,6 +32,11 @@ func {{ $new_executor_function_name }}( {{- if $command.UseConfig }} config *config.Config, {{- end }} + {{- range $field := $command.AdditionalFields -}} + {{ print "" }} + {{ $field.Name }} {{ $field.Type }}, + {{- end -}} + {{ print "" }} ) *{{ $struct_name }} { exe := {{ $struct_name }}{ FlagSet: flag.NewFlagSet({{ printf "%q" $name }}, flag.ExitOnError), @@ -37,6 +46,11 @@ func {{ $new_executor_function_name }}( {{- if $command.UseConfig }} config: config, {{- end }} + {{- range $field := $command.AdditionalFields -}} + {{ print "" }} + {{ $field.Name }}: {{ $field.Name }}, + {{- end -}} + {{ print "" }} } {{ print "" }} exe.Usage = commandUsageFunc({{ printf "%q" $name }}, {{ printf "%q" $command.Summary }}, exe.FlagSet) diff --git a/schema/enbas_cli_schema.json b/schema/enbas_cli_schema.json index e169bd3..e51779f 100644 --- a/schema/enbas_cli_schema.json +++ b/schema/enbas_cli_schema.json @@ -12,26 +12,32 @@ "commands": { "login": { - "usePrinter": true, - "useConfig": true, "flags": [ { "flag": "instance", "default": "" } ], - "summary": "Login to an account on GoToSocial" + "summary": "Log into an account on GoToSocial", + "useConfig": true, + "usePrinter": true }, "version": { - "usePrinter": true, - "useConfig": false, - "summary": "Prints the application's version and build information", + "additionalFields": [ + { "name": "binaryVersion", "type": "string"}, + { "name": "buildTime", "type": "string"}, + { "name": "goVersion", "type": "string"}, + { "name": "gitCommit", "type": "string"} + ], "flags": [ { "flag": "full", "default": "false" } - ] + ], + "summary": "Prints the application's version and build information", + "useConfig": false, + "usePrinter": true }, "whoami": { - "usePrinter": true, - "useConfig": true, + "flags": [], "summary": "Prints the account that you are currently logged into", - "flags": [] + "useConfig": true, + "usePrinter": true } } }