refactor: Pull SQLBoiler debug config up to root cmd

This commit is contained in:
Felicitas Pojtinger
2021-12-08 00:30:47 +01:00
parent 0be10a7698
commit dbeb72fa12
9 changed files with 9 additions and 40 deletions

View File

@@ -13,7 +13,6 @@ import (
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
const (
@@ -46,10 +45,6 @@ var archiveCmd = &cobra.Command{
return keys.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
metadataPersister := persisters.NewMetadataPersister(viper.GetString(metadataFlag))
if err := metadataPersister.Open(); err != nil {
return err

View File

@@ -6,7 +6,6 @@ import (
"github.com/pojntfx/stfs/pkg/operations"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
const (
@@ -29,10 +28,6 @@ var deleteCmd = &cobra.Command{
return keys.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err

View File

@@ -4,7 +4,6 @@ import (
"github.com/pojntfx/stfs/pkg/inventory"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
const (
@@ -20,10 +19,6 @@ var findCmd = &cobra.Command{
return err
}
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
if _, err := inventory.Find(
inventory.MetadataConfig{
Metadata: viper.GetString(metadataFlag),

View File

@@ -4,7 +4,6 @@ import (
"github.com/pojntfx/stfs/pkg/inventory"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
var listCmd = &cobra.Command{
@@ -16,10 +15,6 @@ var listCmd = &cobra.Command{
return err
}
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
if _, err := inventory.List(
inventory.MetadataConfig{
Metadata: viper.GetString(metadataFlag),

View File

@@ -6,7 +6,6 @@ import (
"github.com/pojntfx/stfs/pkg/operations"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
var moveCmd = &cobra.Command{
@@ -25,10 +24,6 @@ var moveCmd = &cobra.Command{
return keys.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err

View File

@@ -10,7 +10,6 @@ import (
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
var recoveryIndexCmd = &cobra.Command{
@@ -28,10 +27,6 @@ var recoveryIndexCmd = &cobra.Command{
return keys.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err

View File

@@ -6,7 +6,6 @@ import (
"github.com/pojntfx/stfs/pkg/operations"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
const (
@@ -29,10 +28,6 @@ var restoreCmd = &cobra.Command{
return keys.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err

View File

@@ -12,6 +12,7 @@ import (
"github.com/pojntfx/stfs/pkg/config"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
const (
@@ -34,6 +35,14 @@ https://github.com/pojntfx/stfs`,
viper.SetEnvPrefix("stbak")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
if err := viper.BindPFlags(cmd.PersistentFlags()); err != nil {
return err
}
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
if err := compression.CheckCompressionFormat(viper.GetString(compressionFlag)); err != nil {
return err
}

View File

@@ -13,7 +13,6 @@ import (
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/volatiletech/sqlboiler/v4/boil"
)
var updateCmd = &cobra.Command{
@@ -40,10 +39,6 @@ var updateCmd = &cobra.Command{
return err
}
if viper.GetBool(verboseFlag) {
boil.DebugMode = true
}
metadataPersister := persisters.NewMetadataPersister(viper.GetString(metadataFlag))
if err := metadataPersister.Open(); err != nil {
return err