{{/* gotype: github.com/wenerme/astgo/pkg/tools/xmlgen.AGICommand*/}} {{- define "agi/command"}} // {{.StructName}}Command {{.Synopsis}} {{- with .Description}} // {{end}} {{- with .Description}}{{template "comment" .}} {{end}} type {{.StructName}}Command struct { {{- range $_,$v:=.Syntax.Params}} {{- with $v.Description}} {{template "comment" (printf "%v %v" $v.Name .)}} {{end}} {{$v.Name}} {{with not $v.Required}}*{{end}}{{$v.Type}} {{with $v.Default}} // default to {{$v.Default}} {{end}} {{- end}} {{with .Syntax.Missing}} // has missing params {{- end}} } func(cmd {{.StructName}}Command)Command() (string, error) { s := []interface{}{cmd.CommandString(),{{- range $_,$v:=.Syntax.Params}} cmd.{{.Name}}, {{- end}}} return joinCommand(s), nil } func(cmd {{.StructName}}Command)CommandString()string { return "{{.Name | upper}}" } {{$s:=.}} {{- range $_,$v:=.Syntax.Params}} {{- if not $v.Required}} func (cmd {{$s.StructName}}Command)Set{{$v.Name}}(v {{$v.Type}}) {{$s.StructName}}Command { cmd.{{$v.Name}} = &v return cmd } {{- end}} {{- end}} func (c *Client) {{$s.StructName}}( {{- range $_,$v:=.Syntax.Params -}} {{- if $v.Required}} {{$v.Name | untitle}} {{$v.Type}}, {{- end -}} {{- end -}} ) Response { return c.Handler.Command({{$s.StructName}}Command{ {{- range $_,$v:=.Syntax.Params}} {{- if $v.Required}} {{$v.Name}}: {{$v.Name | untitle}}, {{- end}} {{- end}} }) } {{- end}} {{/* gotype: github.com/wenerme/astgo/pkg/tools/xmlgen.SyntaxParamDoc*/}} {{- define "agi/command/field"}} {{- with .Description}} {{template "comment" (printf "%v %v" $.Name .)}} {{end}} {{$.Name}} {{with not $.Required}}*{{end}}{{$.Type}} {{with $.Default}} // default to {{$.Default}} {{end}} {{- end}}