diff --git a/openrpc/cmd/cli.go b/openrpc/cmd/cli.go index 27a27c418b0d3e5b1bd9ca1c08af24ee7180068b..8623612e4bb96d929c58b867147bd16ac212d185 100644 --- a/openrpc/cmd/cli.go +++ b/openrpc/cmd/cli.go @@ -56,8 +56,6 @@ func (c *CompileCommand) Run() error { return err } return nil - - return nil } type GenerateCommand struct { diff --git a/openrpc/generate/generate.go b/openrpc/generate/generate.go index 52017e89cd62b6f8c61d55a45534ed10ddc61293..9d773087d05e4d4fe86b134d060154c0d0adb6c4 100644 --- a/openrpc/generate/generate.go +++ b/openrpc/generate/generate.go @@ -9,6 +9,7 @@ import ( "path/filepath" "text/template" + "gfx.cafe/open/jrpc/openrpc/templates" "gfx.cafe/open/jrpc/openrpc/types" "github.com/iancoleman/strcase" ) @@ -45,9 +46,19 @@ var funcs = template.FuncMap{ func Generate(rpc *types.OpenRPC, ts string, output string) error { var wr bytes.Buffer - t, err := template.New(path.Base(ts)).Funcs(funcs).ParseFiles(ts) - if err != nil { - return err + var t *template.Template + var err error + if ts == "default" { + t, err = template.New(path.Base(ts)).Funcs(funcs).Parse(templates.TEMPLATE) + if err != nil { + return err + } + } else { + t, err = template.New(path.Base(ts)).Funcs(funcs).ParseFiles(ts) + if err != nil { + return err + } + } err = t.Execute(&wr, rpc)