Skip to content

Commit

Permalink
#55 Add support for the follow key in the commands config
Browse files Browse the repository at this point in the history
  • Loading branch information
zshamrock committed May 4, 2018
1 parent 1046862 commit 2a8c1dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func CmdRun(c *cli.Context) {
CheckUpdate(c)
follow := ContainsFollow(c)
command, extraArgs := getCommand(c, follow)
if !follow && command.Follow {
follow = command.Follow
}
hosts := getHosts(c, follow)
var confirmation string
if command.RequiresConfirmation {
Expand Down
6 changes: 6 additions & 0 deletions config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
DefaultsConfigFileName = "defaults"
SectionCommandKeyName = "command"
SectionWorkingDirKeyName = "workingdir"
SectionFollowKeyName = "follow"

defaultSectionName = "DEFAULT"
)
Expand Down Expand Up @@ -54,10 +55,15 @@ func readCommands(config VMXConfig, profile string) map[string]core.Command {
if section.HasKey(SectionWorkingDirKeyName) {
workingDir = section.Key(SectionWorkingDirKeyName).String()
}
follow := false
if section.HasKey(SectionFollowKeyName) {
follow, _ = section.Key(SectionFollowKeyName).Bool()
}
commands[name] = core.Command{
Name: name,
Command: section.Key(SectionCommandKeyName).String(),
WorkingDir: workingDir,
Follow: follow,
RequiresConfirmation: requiresConfirmation,
}
}
Expand Down
1 change: 1 addition & 0 deletions core/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (

type Command struct {
Name, Command, WorkingDir string
Follow bool
RequiresConfirmation bool
}

Expand Down

0 comments on commit 2a8c1dd

Please sign in to comment.