From 3851798e216f46ce6a2d15b961a1363dc2a1f162 Mon Sep 17 00:00:00 2001 From: paulknebel Date: Fri, 26 Sep 2025 23:17:29 +0100 Subject: [PATCH 1/2] feat: added soft wrapper around some internal functions --- pkg/api/api.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 pkg/api/api.go diff --git a/pkg/api/api.go b/pkg/api/api.go new file mode 100644 index 0000000000..01df5e94e4 --- /dev/null +++ b/pkg/api/api.go @@ -0,0 +1,43 @@ +package api + +import ( + "bytes" + "context" + "fmt" + "path/filepath" + "regexp" + "strconv" + "strings" + "time" + + "github.com/sqlc-dev/sqlc/internal/cmd" +) + +type Options struct { + Dir string // working directory for relative paths + Filename string + Options *cmd.Options +} + +type Diagnostic struct { + File string + Line int + Column int + Severity string // "error" | "warning" | "info" + Message string + Raw string +} + +type Report struct { + Stdout string + Stderr string + Diagnostics []Diagnostic +} + +func Generate(ctx context.Context, opt Options) (map[string]string, error) { + return cmd.Generate(ctx, opt.Dir, opt.Filename, opt.Options) +} + +func Verify(ctx context.Context, opt Options) error { + return cmd.Verify(ctx, opt.Dir, opt.Filename, opt.Options) +} From 214dfbc9e59f9c73e84e33b608133cc257ec91ed Mon Sep 17 00:00:00 2001 From: paulknebel Date: Fri, 26 Sep 2025 23:19:41 +0100 Subject: [PATCH 2/2] feat: added soft wrapper around some internal functions --- pkg/api/api.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 01df5e94e4..13a2613f19 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -1,14 +1,7 @@ package api import ( - "bytes" "context" - "fmt" - "path/filepath" - "regexp" - "strconv" - "strings" - "time" "github.com/sqlc-dev/sqlc/internal/cmd" ) @@ -19,21 +12,6 @@ type Options struct { Options *cmd.Options } -type Diagnostic struct { - File string - Line int - Column int - Severity string // "error" | "warning" | "info" - Message string - Raw string -} - -type Report struct { - Stdout string - Stderr string - Diagnostics []Diagnostic -} - func Generate(ctx context.Context, opt Options) (map[string]string, error) { return cmd.Generate(ctx, opt.Dir, opt.Filename, opt.Options) } @@ -41,3 +19,7 @@ func Generate(ctx context.Context, opt Options) (map[string]string, error) { func Verify(ctx context.Context, opt Options) error { return cmd.Verify(ctx, opt.Dir, opt.Filename, opt.Options) } + +func Vet(ctx context.Context, opt Options) error { + return cmd.Vet(ctx, opt.Dir, opt.Filename, opt.Options) +}