cli.go 631 B

123456789101112131415161718192021222324252627282930
  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/sqlc-dev/sqlc/pkg/cli"
  12. // )
  13. //
  14. // func main() {
  15. // os.Exit(sqlc.Run(os.Args[1:]))
  16. // }
  17. package cli
  18. import (
  19. "os"
  20. "github.com/sqlc-dev/sqlc/internal/cmd"
  21. )
  22. // Run the sqlc CLI. It takes an array of command-line arguments
  23. // (excluding the executable argument itself) and returns an exit
  24. // code.
  25. func Run(args []string) int {
  26. return cmd.Do(args, os.Stdin, os.Stdout, os.Stderr)
  27. }