-
Notifications
You must be signed in to change notification settings - Fork 567
/
main.go
45 lines (38 loc) · 1.28 KB
/
main.go
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
36
37
38
39
40
41
42
43
44
45
package main
import (
"os/signal"
"github.com/spf13/cobra"
"github.com/pachyderm/pachyderm/v2/src/internal/log"
"github.com/pachyderm/pachyderm/v2/src/internal/pachdev"
"github.com/pachyderm/pachyderm/v2/src/internal/pctx"
"github.com/pachyderm/pachyderm/v2/src/internal/signals"
)
var verbose bool
func main() {
rootCmd := &cobra.Command{
Use: "pachdev",
Short: "A CLI tool for Pachyderm development",
SilenceUsage: true, // This avoids printing the usage message on errors.
SilenceErrors: true, // We print out the error ourselves.
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if verbose {
log.SetLevel(log.DebugLevel)
}
},
}
// Common flags.
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "If true, show debug-level log messages.")
// Subcommands.
rootCmd.AddCommand(pachdev.DeleteClusterCmd())
rootCmd.AddCommand(pachdev.CreateClusterCmd())
rootCmd.AddCommand(pachdev.LoadImageCmd())
rootCmd.AddCommand(pachdev.PushPachydermCmd())
rootCmd.AddCommand(pachdev.ServeCoverageCmd())
// Run a command.
log.InitPachctlLogger()
ctx, c := signal.NotifyContext(pctx.Background(""), signals.TerminationSignals...)
defer c()
if err := rootCmd.ExecuteContext(ctx); err != nil {
log.Exit(ctx, err.Error())
}
}