Andrew
059f4c0097
- Added `cron` command to run lists with `cron` time specifed - Changed `-c` flag to `-f` flag for passing config file - Modified some config keys - cmdArgs -> Args - Got rid of `hosts.config` - better SSH handling - respects values in config file
35 lines
722 B
Go
35 lines
722 B
Go
// exec.go
|
|
// Copyright (C) Andrew Woodlee 2023
|
|
// License: Apache-2.0
|
|
|
|
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{
|
|
Use: "exec command ...",
|
|
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))
|
|
opts.InitConfig()
|
|
// opts.InitMongo()
|
|
backy.ReadConfig(opts).ExecuteCmds()
|
|
|
|
}
|