Files
backy/cmd/exec.go
T
CyberShell 5f6459d5be
ci/woodpecker/push/publish-docs Pipeline is pending
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline was successful
v0.13.1
2026-08-15 09:53:03 -05:00

46 lines
970 B
Go
Executable File

// exec.go
// Copyright (C) Andrew Woodlee 2023
// License: Apache-2.0
package cmd
import (
"fmt"
"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 in order given.",
Long: `Exec executes commands defined in config file in order given.`,
Run: execute,
}
)
func init() {
execCmd.AddCommand(hostExecCommand, hostsExecCommand)
}
func execute(cmd *cobra.Command, args []string) {
parseS3Config()
if len(args) < 1 {
logging.ExitWithMSG(fmt.Sprintf("Please provide a command to run.\n\n%s", cmd.Long), 1, nil)
}
opts := backy.NewConfigOptions(configFile,
backy.AddCommands(args),
backy.SetLogFile(logFile),
backy.EnableCommandStdOut(cmdStdOut),
backy.SetHostsConfigFile(hostsConfigFile))
opts.InitConfig()
opts.ParseConfigurationFile()
opts.ExecuteCmds()
}