Close host connections after all command have been run, added some flags to version subcommand
This commit is contained in:
@ -33,4 +33,9 @@ func Backup(cmd *cobra.Command, args []string) {
|
||||
backyConfOpts.InitConfig()
|
||||
config := backy.ReadConfig(backyConfOpts)
|
||||
config.RunBackyConfig("")
|
||||
for _, host := range config.Hosts {
|
||||
if host.SshClient != nil {
|
||||
host.SshClient.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,21 @@ const versionStr = "0.2.4"
|
||||
|
||||
var (
|
||||
versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Use: "version [flags]",
|
||||
Short: "Prints the version and exits.",
|
||||
Run: version,
|
||||
}
|
||||
numOnly bool
|
||||
)
|
||||
|
||||
func version(cmd *cobra.Command, args []string) {
|
||||
|
||||
fmt.Printf("%s\n", versionStr)
|
||||
cmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", true, "Output the version number only.")
|
||||
if numOnly {
|
||||
fmt.Printf("%s\n", versionStr)
|
||||
} else {
|
||||
fmt.Printf("Version: %s", versionStr)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user