-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (28 loc) · 818 Bytes
/
Copy pathmain.go
File metadata and controls
35 lines (28 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// package main is the entry point of pgxcli.
// It initializes the CLI application and executes the root command.
//
// The main function sets up the context, initializes the printer for output
// and error messages, and creates the root command of the CLI application.
package main
import (
"context"
"os"
"github.com/balajz/pgxcli/internal/cli"
"github.com/balajz/pgxcli/internal/cliio"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
printer := cliio.NewPgxPrinter(os.Stdout, os.Stderr)
cliCtx := &cli.CliContext{Printer: printer}
rootCmd := cli.NewRootCmd(
ctx,
cliCtx,
)
if err := rootCmd.ExecuteContext(ctx); err != nil {
printer.PrintError(err)
os.Exit(1)
}
printer.Println("Thanks for using Pgxcli.")
printer.Println("see you next time.")
}