mirror of
https://github.com/Luzifer/ots.git
synced 2024-10-01 01:06:09 -04:00
36 lines
815 B
Go
36 lines
815 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Luzifer/ots/pkg/client"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Short: "Utility to interact with encrypted secrets in an OTS instance",
|
|
PersistentPreRunE: rootPersistentPreRunE,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.PersistentFlags().String("log-level", "info", "Level to use for logging (trace, debug, info, warn, error, fatal)")
|
|
}
|
|
|
|
func rootPersistentPreRunE(cmd *cobra.Command, _ []string) error {
|
|
sll, err := cmd.Flags().GetString("log-level")
|
|
if err != nil {
|
|
return fmt.Errorf("getting log-level: %w", err)
|
|
}
|
|
|
|
ll, err := logrus.ParseLevel(sll)
|
|
if err != nil {
|
|
return fmt.Errorf("parsing log-level: %w", err)
|
|
}
|
|
logrus.SetLevel(ll)
|
|
|
|
client.Logger = logrus.NewEntry(logrus.StandardLogger())
|
|
|
|
return nil
|
|
}
|