|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"darvaza.org/sidecar/pkg/logger/zerolog" |
|
|
|
|
"darvaza.org/slog" |
|
|
|
|
"github.com/spf13/cobra" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -10,13 +12,29 @@ const (
|
|
|
|
|
CmdName = "jpictl" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var rootCmd = &cobra.Command{ |
|
|
|
|
var ( |
|
|
|
|
log = zerolog.New(nil, slog.Error) |
|
|
|
|
verbosity int |
|
|
|
|
rootCmd = &cobra.Command{ |
|
|
|
|
Use: CmdName, |
|
|
|
|
Short: "control tool for jpi.cloud", |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
|
if err := rootCmd.Execute(); err != nil { |
|
|
|
|
fatal(err, "") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
|
rootCmd.PersistentFlags().CountVarP(&verbosity, "verbosity", "v", "increase the verbosity level to Warn, Info or Debug") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func setVerbosity(_ *cobra.Command, _ []string) { |
|
|
|
|
desired := int8(slog.Error) + int8(verbosity) |
|
|
|
|
if desired > 6 { |
|
|
|
|
desired = 6 |
|
|
|
|
} |
|
|
|
|
log = log.WithLevel(slog.LogLevel(desired)) |
|
|
|
|
} |
|
|
|
|