2023-01-10 04:18:56 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
2023-01-17 06:55:28 +00:00
|
|
|
"git.andrewnw.xyz/CyberShell/backy/pkg/notifications"
|
2023-01-10 04:18:56 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
backupCmd = &cobra.Command{
|
|
|
|
Use: "backup [--commands==list1,list2]",
|
|
|
|
Short: "Runs commands defined in config file.",
|
|
|
|
Long: `Backup executes commands defined in config file,
|
|
|
|
use the -cmds flag to execute the specified commands.`,
|
2023-01-17 06:55:28 +00:00
|
|
|
Run: Backup,
|
2023-01-10 04:18:56 +00:00
|
|
|
}
|
|
|
|
)
|
2023-01-17 06:55:28 +00:00
|
|
|
var CmdList []string
|
2023-01-10 04:18:56 +00:00
|
|
|
|
|
|
|
func init() {
|
2023-01-17 06:55:28 +00:00
|
|
|
// cobra.OnInitialize(initConfig)
|
|
|
|
|
|
|
|
backupCmd.Flags().StringSliceVar(&CmdList, "cmds", nil, "Accepts a comma-separated list of command lists to execute.")
|
2023-01-10 04:18:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-01-17 06:55:28 +00:00
|
|
|
func Backup(cmd *cobra.Command, args []string) {
|
|
|
|
config := backy.ReadAndParseConfigFile(cfgFile)
|
|
|
|
notifications.SetupNotify(*config)
|
|
|
|
config.RunBackyConfig()
|
2023-01-10 04:18:56 +00:00
|
|
|
}
|