cli.go 670 B

12345678910111213141516171819202122232425262728293031
  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. import (
  20. "os"
  21. "github.com/kyleconroy/sqlc/internal/cmd"
  22. )
  23. // Run the sqlc CLI. It takes an array of command-line arguments
  24. // (excluding the executable argument itself) and returns an exit
  25. // code.
  26. func Run(args []string) int {
  27. return cmd.Do(args, os.Stdin, os.Stdout, os.Stderr)
  28. }