-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package opts | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
//"maps" | ||
///"path/filepath" | ||
|
||
"github.com/sqlc-dev/plugin-sdk-go/plugin" | ||
) | ||
|
||
type Options struct { | ||
OutputModelsFileName string `json:"output_models_file_name,omitempty" yaml:"output_models_file_name"` | ||
} | ||
|
||
func Parse(req *plugin.GenerateRequest) (*Options, error) { | ||
options, err := parseOpts(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return options, nil | ||
} | ||
|
||
func parseOpts(req *plugin.GenerateRequest) (*Options, error) { | ||
var options Options | ||
if len(req.PluginOptions) == 0 { | ||
return &options, nil | ||
} | ||
if err := json.Unmarshal(req.PluginOptions, &options); err != nil { | ||
return nil, fmt.Errorf("unmarshalling plugin options: %w", err) | ||
} | ||
|
||
return &options, nil | ||
} | ||
|
||
func ValidateOpts(opts *Options) error { | ||
// TODO: validate options | ||
|
||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package perl | ||
|
||
import "embed" | ||
|
||
//go:embed templates/* | ||
var templates embed.FS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{define "modelsFile"}} | ||
# Code generated by sqlc. DO NOT EDIT. | ||
# versions: | ||
# sqlc: {{.SqlcVersion}} | ||
|
||
package Models; | ||
use strict; | ||
use warnings; | ||
|
||
{{template "modelsCode" .}} | ||
|
||
1; | ||
{{end}} | ||
|
||
{{define "modelsCode"}} | ||
Hello | ||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package perl | ||
|
||
import "embed" | ||
|
||
//go:embed templates/* | ||
//go:embed templates/*/* | ||
var templates embed.FS |