2023-02-02 05:45:23 +00:00
|
|
|
// exec.go
|
|
|
|
// Copyright (C) Andrew Woodlee 2023
|
|
|
|
// License: Apache-2.0
|
|
|
|
|
2023-01-20 08:42:52 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
|
|
|
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
execCmd = &cobra.Command{
|
2023-02-02 05:45:23 +00:00
|
|
|
Use: "exec command ...",
|
2023-07-02 02:46:54 +00:00
|
|
|
Short: "Runs commands defined in config file in order given.",
|
|
|
|
Long: `Exec executes commands defined in config file in order given.`,
|
2023-01-20 08:42:52 +00:00
|
|
|
Run: execute,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func execute(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
if len(args) < 1 {
|
2023-09-09 04:42:13 +00:00
|
|
|
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 1, nil)
|
2023-01-20 08:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opts := backy.NewOpts(cfgFile, backy.AddCommands(args))
|
2023-02-02 05:45:23 +00:00
|
|
|
opts.InitConfig()
|
|
|
|
// opts.InitMongo()
|
2023-02-19 04:42:15 +00:00
|
|
|
backy.ReadConfig(opts).ExecuteCmds(opts)
|
2023-01-20 08:42:52 +00:00
|
|
|
}
|