Skip to content

Commit c346ddd

Browse files
committed
add pkg/cli package
Closes #416
1 parent a94163b commit c346ddd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pkg/cli/cli.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// package cli exposes the command-line interface for sqlc. It can be used to
2+
// run sqlc from Go without the overhead of creating a child process.
3+
//
4+
// Example usage:
5+
//
6+
// package main
7+
//
8+
// import (
9+
// "os"
10+
//
11+
// sqlc "github.com/kyleconroy/sqlc/pkg/cli"
12+
// )
13+
//
14+
// func main() {
15+
// os.Exit(sqlc.Run(os.Args[1:]))
16+
// }
17+
//
18+
package cli
19+
20+
import (
21+
"os"
22+
23+
"github.com/kyleconroy/sqlc/internal/cmd"
24+
)
25+
26+
// Run the sqlc CLI. It takes an array of command-line arguments
27+
// (excluding the executable argument itself) and returns an exit
28+
// code.
29+
func Run(args []string) int {
30+
return cmd.Do(args, os.Stdin, os.Stdout, os.Stderr)
31+
}

0 commit comments

Comments
 (0)