From c346dddaea9bd675e4b3f2da20c8ba51b6b15fd4 Mon Sep 17 00:00:00 2001 From: oliverpool <3864879+oliverpool@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:40:33 +0200 Subject: [PATCH] add pkg/cli package Closes #416 --- pkg/cli/cli.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkg/cli/cli.go diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go new file mode 100644 index 0000000000..695c0c4bc4 --- /dev/null +++ b/pkg/cli/cli.go @@ -0,0 +1,31 @@ +// package cli exposes the command-line interface for sqlc. It can be used to +// run sqlc from Go without the overhead of creating a child process. +// +// Example usage: +// +// package main +// +// import ( +// "os" +// +// sqlc "github.com/kyleconroy/sqlc/pkg/cli" +// ) +// +// func main() { +// os.Exit(sqlc.Run(os.Args[1:])) +// } +// +package cli + +import ( + "os" + + "github.com/kyleconroy/sqlc/internal/cmd" +) + +// Run the sqlc CLI. It takes an array of command-line arguments +// (excluding the executable argument itself) and returns an exit +// code. +func Run(args []string) int { + return cmd.Do(args, os.Stdin, os.Stdout, os.Stderr) +}