checkpoint: additional fields
This commit is contained in:
parent
e16852da97
commit
d1f5e57703
3 changed files with 40 additions and 14 deletions
|
@ -53,13 +53,19 @@ func (e enbasCLISchemaFlagMap) getDescription(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type enbasCLISchemaCommand struct {
|
type enbasCLISchemaCommand struct {
|
||||||
UsePrinter bool `json:"usePrinter"`
|
AdditionalFields []enbasCLISchemaAdditionalFields `json:"additionalFields"`
|
||||||
UseConfig bool `json:"useConfig"`
|
Flags []enbasCLISchemaFlagReference `json:"flags"`
|
||||||
Flags []enbasCLISchemaFlagReference `json:"flags"`
|
Summary string `json:"summary"`
|
||||||
Summary string `json:"summary"`
|
UseConfig bool `json:"useConfig"`
|
||||||
|
UsePrinter bool `json:"usePrinter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type enbasCLISchemaFlagReference struct {
|
type enbasCLISchemaFlagReference struct {
|
||||||
Flag string `json:"flag"`
|
Flag string `json:"flag"`
|
||||||
Default string `json:"default"`
|
Default string `json:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type enbasCLISchemaAdditionalFields struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@ type {{ $struct_name }} struct {
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
{{ $flag.Flag }} {{ getFlagType $flag.Flag }}
|
{{ $flag.Flag }} {{ getFlagType $flag.Flag }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{- range $field := $command.AdditionalFields -}}
|
||||||
|
{{ print "" }}
|
||||||
|
{{ $field.Name }} {{ $field.Type }}
|
||||||
|
{{- end -}}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +32,11 @@ func {{ $new_executor_function_name }}(
|
||||||
{{- if $command.UseConfig }}
|
{{- if $command.UseConfig }}
|
||||||
config *config.Config,
|
config *config.Config,
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- range $field := $command.AdditionalFields -}}
|
||||||
|
{{ print "" }}
|
||||||
|
{{ $field.Name }} {{ $field.Type }},
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
) *{{ $struct_name }} {
|
) *{{ $struct_name }} {
|
||||||
exe := {{ $struct_name }}{
|
exe := {{ $struct_name }}{
|
||||||
FlagSet: flag.NewFlagSet({{ printf "%q" $name }}, flag.ExitOnError),
|
FlagSet: flag.NewFlagSet({{ printf "%q" $name }}, flag.ExitOnError),
|
||||||
|
@ -37,6 +46,11 @@ func {{ $new_executor_function_name }}(
|
||||||
{{- if $command.UseConfig }}
|
{{- if $command.UseConfig }}
|
||||||
config: config,
|
config: config,
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- range $field := $command.AdditionalFields -}}
|
||||||
|
{{ print "" }}
|
||||||
|
{{ $field.Name }}: {{ $field.Name }},
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
}
|
}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
exe.Usage = commandUsageFunc({{ printf "%q" $name }}, {{ printf "%q" $command.Summary }}, exe.FlagSet)
|
exe.Usage = commandUsageFunc({{ printf "%q" $name }}, {{ printf "%q" $command.Summary }}, exe.FlagSet)
|
||||||
|
|
|
@ -12,26 +12,32 @@
|
||||||
|
|
||||||
"commands": {
|
"commands": {
|
||||||
"login": {
|
"login": {
|
||||||
"usePrinter": true,
|
|
||||||
"useConfig": true,
|
|
||||||
"flags": [
|
"flags": [
|
||||||
{ "flag": "instance", "default": "" }
|
{ "flag": "instance", "default": "" }
|
||||||
],
|
],
|
||||||
"summary": "Login to an account on GoToSocial"
|
"summary": "Log into an account on GoToSocial",
|
||||||
|
"useConfig": true,
|
||||||
|
"usePrinter": true
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"usePrinter": true,
|
"additionalFields": [
|
||||||
"useConfig": false,
|
{ "name": "binaryVersion", "type": "string"},
|
||||||
"summary": "Prints the application's version and build information",
|
{ "name": "buildTime", "type": "string"},
|
||||||
|
{ "name": "goVersion", "type": "string"},
|
||||||
|
{ "name": "gitCommit", "type": "string"}
|
||||||
|
],
|
||||||
"flags": [
|
"flags": [
|
||||||
{ "flag": "full", "default": "false" }
|
{ "flag": "full", "default": "false" }
|
||||||
]
|
],
|
||||||
|
"summary": "Prints the application's version and build information",
|
||||||
|
"useConfig": false,
|
||||||
|
"usePrinter": true
|
||||||
},
|
},
|
||||||
"whoami": {
|
"whoami": {
|
||||||
"usePrinter": true,
|
"flags": [],
|
||||||
"useConfig": true,
|
|
||||||
"summary": "Prints the account that you are currently logged into",
|
"summary": "Prints the account that you are currently logged into",
|
||||||
"flags": []
|
"useConfig": true,
|
||||||
|
"usePrinter": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue