MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / Do

Function Do

internal/cmd/cmd.go:37–77  ·  view source on GitHub ↗

Do runs the command logic.

(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer)

Source from the content-addressed store, hash-verified

35
36// Do runs the command logic.
37func Do(args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int {
38 rootCmd := &cobra.Command{Use: "sqlc", SilenceUsage: true}
39 rootCmd.PersistentFlags().StringP("file", "f", "", "specify an alternate config file (default: sqlc.yaml)")
40 rootCmd.PersistentFlags().Bool("no-remote", false, "disable remote execution (default: false)")
41 rootCmd.PersistentFlags().Bool("remote", false, "enable remote execution (default: false)")
42
43 rootCmd.AddCommand(checkCmd)
44 rootCmd.AddCommand(createDBCmd)
45 rootCmd.AddCommand(diffCmd)
46 rootCmd.AddCommand(genCmd)
47 rootCmd.AddCommand(initCmd)
48 rootCmd.AddCommand(parseCmd)
49 rootCmd.AddCommand(versionCmd)
50 rootCmd.AddCommand(verifyCmd)
51 rootCmd.AddCommand(pushCmd)
52 rootCmd.AddCommand(NewCmdVet())
53
54 rootCmd.SetArgs(args)
55 rootCmd.SetIn(stdin)
56 rootCmd.SetOut(stdout)
57 rootCmd.SetErr(stderr)
58
59 ctx := context.Background()
60 if debug.Debug.Trace != "" {
61 tracectx, cleanup, err := tracer.Start(ctx)
62 if err != nil {
63 fmt.Printf("failed to start trace: %v\n", err)
64 return 1
65 }
66 ctx = tracectx
67 defer cleanup()
68 }
69 if err := rootCmd.ExecuteContext(ctx); err != nil {
70 if exitError, ok := err.(*exec.ExitError); ok {
71 return exitError.ExitCode()
72 } else {
73 return 1
74 }
75 }
76 return 0
77}
78
79var version string
80

Callers 2

RunFunction · 0.92
mainFunction · 0.92

Calls 2

StartFunction · 0.92
NewCmdVetFunction · 0.85

Tested by

no test coverage detected