2023-02-02 05:45:23 +00:00
// backup.go
// Copyright (C) Andrew Woodlee 2023
// License: Apache-2.0
2023-01-10 04:18:56 +00:00
package cmd
import (
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
"github.com/spf13/cobra"
)
var (
backupCmd = & cobra . Command {
2023-02-19 04:42:15 +00:00
Use : "backup [--lists=list1,list2]" ,
2023-01-10 04:18:56 +00:00
Short : "Runs commands defined in config file." ,
2023-02-19 04:42:15 +00:00
Long : "Backup executes commands defined in config file.\nUse the --lists flag to execute the specified commands. If not specified, all lists will be executed." ,
Run : Backup ,
2023-01-10 04:18:56 +00:00
}
)
2023-01-20 08:42:52 +00:00
// Holds command list to run
2023-02-02 05:45:23 +00:00
var cmdLists [ ] string
2023-01-10 04:18:56 +00:00
func init ( ) {
2023-01-17 06:55:28 +00:00
2023-02-12 05:50:19 +00:00
backupCmd . Flags ( ) . StringSliceVarP ( & cmdLists , "lists" , "l" , nil , "Accepts comma-separated names 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 ) {
2023-02-02 05:45:23 +00:00
backyConfOpts := backy . NewOpts ( cfgFile , backy . AddCommandLists ( cmdLists ) )
backyConfOpts . InitConfig ( )
config := backy . ReadConfig ( backyConfOpts )
config . RunBackyConfig ( "" )
2023-01-10 04:18:56 +00:00
}