Skip to content

Commit

Permalink
#77 Allow to specify multiple hosts for the run command using comma
Browse files Browse the repository at this point in the history
  • Loading branch information
zshamrock committed Nov 25, 2018
1 parent 766c8b8 commit 7a67986
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
hostsGroupArgsIndex = 0
commandNameArgsIndex = 1
extraArgsPlaceholder = "%s"
hostsSeparator = ","
FollowArgName = "follow"
)

Expand Down Expand Up @@ -126,8 +127,11 @@ func ContainsFollow(c *cli.Context) bool {
func getHosts(c *cli.Context, follow bool) []string {
args := c.Args()
actualHostsGroupArgsIndex := getActualArgsIndex(hostsGroupArgsIndex, follow)
hostsGroup := strings.TrimSpace(args.Get(actualHostsGroupArgsIndex))
hosts := getHostsByGroup(c, hostsGroup)
hostsGroups := strings.Split(strings.TrimSpace(args.Get(actualHostsGroupArgsIndex)), hostsSeparator)
hosts := make([]string, 0, len(hostsGroups))
for _, hostsGroup := range hostsGroups {
hosts = append(hosts, getHostsByGroup(c, hostsGroup)...)
}
sort.Strings(hosts)
return hosts
}
Expand Down

0 comments on commit 7a67986

Please sign in to comment.