backy/cmd/root.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

41 lines
805 B
Go

// root.go
// Copyright (C) Andrew Woodlee 2023
// License: Apache-2.0
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var (
// Used for flags.
cfgFile string
verbose bool
rootCmd = &cobra.Command{
Use: "backy",
Short: "An easy-to-configure backup tool.",
Long: `Backy is a command-line application useful for configuring backups, or any commands run in sequence.`,
}
)
// Execute executes the root command.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "f", "", "config file to read from")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Sets verbose level")
rootCmd.AddCommand(backupCmd, execCmd, cronCmd, versionCmd)
}