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-01-20 08:42:52 +00:00
|
|
|
Short: "Runs commands defined in config file.",
|
|
|
|
Long: `Exec executes commands defined in config file.`,
|
|
|
|
Run: execute,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func execute(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
if len(args) < 1 {
|
|
|
|
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 0, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|