mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-04 09:40:39 +00:00
1.5.4
This commit is contained in:
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/flags"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -12,7 +13,7 @@ var cronCmd = &cobra.Command{
|
||||
Long: `Intended to be mainly triggered by an automated system like systemd or crontab. For each location checks if a cron backup is due and runs it.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
internal.CRON_LEAN, _ = cmd.Flags().GetBool("lean")
|
||||
flags.CRON_LEAN, _ = cmd.Flags().GetBool("lean")
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
12
cmd/root.go
12
cmd/root.go
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/flags"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -37,8 +38,8 @@ func Execute() {
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.autorestic.yml or ./.autorestic.yml)")
|
||||
rootCmd.PersistentFlags().BoolVar(&internal.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity")
|
||||
rootCmd.PersistentFlags().BoolVarP(&internal.VERBOSE, "verbose", "v", false, "verbose mode")
|
||||
rootCmd.PersistentFlags().BoolVar(&flags.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity")
|
||||
rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode")
|
||||
rootCmd.PersistentFlags().StringVar(&internal.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary")
|
||||
cobra.OnInitialize(initConfig)
|
||||
}
|
||||
@@ -46,13 +47,10 @@ func init() {
|
||||
func initConfig() {
|
||||
if ci, _ := rootCmd.Flags().GetBool("ci"); ci {
|
||||
colors.DisableColors(true)
|
||||
internal.VERBOSE = true
|
||||
flags.VERBOSE = true
|
||||
}
|
||||
|
||||
if cfgFile != "" {
|
||||
if internal.VERBOSE {
|
||||
colors.Faint.Printf("> Using config file: %s\n", cfgFile)
|
||||
}
|
||||
viper.SetConfigFile(cfgFile)
|
||||
viper.AutomaticEnv()
|
||||
if viper.ConfigFileUsed() == "" {
|
||||
@@ -81,7 +79,7 @@ func initConfig() {
|
||||
for _, cfgPath := range configPaths {
|
||||
viper.AddConfigPath(cfgPath)
|
||||
}
|
||||
if internal.VERBOSE {
|
||||
if flags.VERBOSE {
|
||||
colors.Faint.Printf("Using config paths: %s\n", strings.Join(configPaths, " "))
|
||||
}
|
||||
cfgFileName := ".autorestic"
|
||||
|
Reference in New Issue
Block a user