Implement OTS-CLI utility (#117)

This commit is contained in:
Knut Ahlers 2023-10-04 22:27:14 +02:00 committed by GitHub
parent c5124731f5
commit 546481dcfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 861 additions and 70 deletions

32
cmd/ots-cli/cmd_root.go Normal file
View file

@ -0,0 +1,32 @@
package main
import (
"fmt"
"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)
return nil
}