backy/cmd/exec.go
Andrew 059f4c0097 added some features
- 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
2023-02-01 23:54:48 -06:00

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()
}