This commit is contained in:
2021-04-11 13:04:11 +02:00
parent 43244302be
commit 335724cce7
12 changed files with 315 additions and 34 deletions

View File

@@ -31,20 +31,19 @@ var execCmd = &cobra.Command{
if err := config.CheckConfig(); err != nil {
panic(err)
}
exec(internal.GetAllOrLocation(cmd, true), config, args)
{
selected, err := internal.GetAllOrSelected(cmd, true)
cobra.CheckErr(err)
for _, name := range selected {
fmt.Println(name)
backend := config.Backends[name]
backend.Exec(args)
}
}
},
}
func init() {
rootCmd.AddCommand(execCmd)
execCmd.PersistentFlags().StringSliceP("backend", "b", []string{}, "backends")
execCmd.PersistentFlags().BoolP("all", "a", false, "Exec in all backends")
}
func exec(backends []string, config *internal.Config, args []string) {
for _, name := range backends {
fmt.Println(name)
backend := config.Backends[name]
backend.Exec(args)
}
internal.AddFlagsToCommand(execCmd, true)
}