You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
786 B
40 lines
786 B
// Package main implements the jpictl command |
|
package main |
|
|
|
import ( |
|
"darvaza.org/sidecar/pkg/logger/zerolog" |
|
"darvaza.org/slog" |
|
"github.com/spf13/cobra" |
|
) |
|
|
|
const ( |
|
// CmdName is the name of the executable |
|
CmdName = "jpictl" |
|
) |
|
|
|
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)) |
|
}
|
|
|