backy/cmd/exec.go
Andrew ee83586072 Version 0.2.4
* Notifications now display errors and the output of the failed command.
* CI configs for GitHub and Woodpecker
* Added `version` subcommand
* Console logging can be disabled by setting `console-disabled` in the
`logging` object
* If Host was not defined for an incomplete `hosts` object, any commands
would fail as they could not look up the values in the SSH config files.
2023-02-18 22:42:15 -06:00

34 lines
725 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(opts)
}