2023-01-17 06:55:28 +00:00
|
|
|
// root.go
|
|
|
|
// Copyright (C) Andrew Woodlee 2023
|
|
|
|
// License: Apache-2.0
|
|
|
|
|
2022-12-15 16:42:21 +00:00
|
|
|
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.",
|
2023-01-17 06:55:28 +00:00
|
|
|
Long: `Backy is a command-line application useful for configuring backups, or any commands run in sequence.`,
|
2022-12-15 16:42:21 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// Execute executes the root command.
|
2023-01-17 06:55:28 +00:00
|
|
|
func Execute() {
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2022-12-15 16:42:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
2023-02-02 05:45:23 +00:00
|
|
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "f", "", "config file to read from")
|
2022-12-15 16:42:21 +00:00
|
|
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Sets verbose level")
|
2023-01-10 04:18:56 +00:00
|
|
|
|
2023-02-19 04:42:15 +00:00
|
|
|
rootCmd.AddCommand(backupCmd, execCmd, cronCmd, versionCmd)
|
2022-12-15 16:42:21 +00:00
|
|
|
}
|