v0.4.0
Some checks failed
ci/woodpecker/push/gitea Pipeline was successful
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/go-lint Pipeline failed
ci/woodpecker/tag/publish-docs Pipeline is running
ci/woodpecker/push/publish-docs Pipeline was successful
Some checks failed
ci/woodpecker/push/gitea Pipeline was successful
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/go-lint Pipeline failed
ci/woodpecker/tag/publish-docs Pipeline is running
ci/woodpecker/push/publish-docs Pipeline was successful
This commit is contained in:
@ -32,10 +32,10 @@ func Backup(cmd *cobra.Command, args []string) {
|
||||
backyConfOpts := backy.NewOpts(cfgFile, backy.AddCommandLists(cmdLists))
|
||||
backyConfOpts.InitConfig()
|
||||
|
||||
config := backy.ReadConfig(backyConfOpts)
|
||||
backy.ReadConfig(backyConfOpts)
|
||||
|
||||
config.RunListConfig("", backyConfOpts)
|
||||
for _, host := range config.Hosts {
|
||||
backyConfOpts.RunListConfig("")
|
||||
for _, host := range backyConfOpts.Hosts {
|
||||
if host.SshClient != nil {
|
||||
host.SshClient.Close()
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ var (
|
||||
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)
|
||||
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 1, nil)
|
||||
}
|
||||
|
||||
opts := backy.NewOpts(cfgFile, backy.AddCommands(args))
|
||||
|
39
cmd/list.go
Normal file
39
cmd/list.go
Normal file
@ -0,0 +1,39 @@
|
||||
// backup.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
listCmd = &cobra.Command{
|
||||
Use: "list [--list=list1,list2,... | -l list1, list2,...] [ -cmd cmd1 cmd2 cmd3...]",
|
||||
Short: "Lists commands, lists, or hosts defined in config file.",
|
||||
Long: "Backup lists commands or groups defined in config file.\nUse the --lists or -l flag to list the specified lists. If not flag is not given, all lists will be executed.",
|
||||
Run: List,
|
||||
}
|
||||
)
|
||||
|
||||
var listsToList []string
|
||||
|
||||
func init() {
|
||||
|
||||
listCmd.Flags().StringSliceVarP(&listsToList, "lists", "l", nil, "Accepts comma-separated names of command lists to list.")
|
||||
|
||||
}
|
||||
|
||||
func List(cmd *cobra.Command, args []string) {
|
||||
|
||||
opts := backy.NewOpts(cfgFile, backy.SetListsToSearch(cmdLists))
|
||||
|
||||
opts.InitConfig()
|
||||
|
||||
opts = backy.ReadConfig(opts)
|
||||
|
||||
opts.ListConfiguration()
|
||||
}
|
@ -36,5 +36,5 @@ 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)
|
||||
rootCmd.AddCommand(backupCmd, execCmd, cronCmd, versionCmd, listCmd)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const versionStr = "0.3.1"
|
||||
const versionStr = "0.4.0"
|
||||
|
||||
var (
|
||||
versionCmd = &cobra.Command{
|
||||
@ -32,9 +32,6 @@ func version(cmd *cobra.Command, args []string) {
|
||||
} else if vPre && !numOnly {
|
||||
fmt.Printf("v%s\n", versionStr)
|
||||
} else {
|
||||
if vPre && numOnly {
|
||||
fmt.Println("vpre flag and num flag both detected!")
|
||||
}
|
||||
fmt.Printf("Backy version: %s\n", versionStr)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user