From 2a8c1dd558b2a555651313376a344107a7c4cb1a Mon Sep 17 00:00:00 2001 From: Aliaksandr Kazlou Date: Fri, 4 May 2018 23:28:16 +0300 Subject: [PATCH] #55 Add support for the follow key in the commands config --- command/run.go | 3 +++ config/init.go | 6 ++++++ core/command.go | 1 + 3 files changed, 10 insertions(+) diff --git a/command/run.go b/command/run.go index a317339..7646193 100644 --- a/command/run.go +++ b/command/run.go @@ -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 { diff --git a/config/init.go b/config/init.go index 136b8ed..976360e 100644 --- a/config/init.go +++ b/config/init.go @@ -17,6 +17,7 @@ const ( DefaultsConfigFileName = "defaults" SectionCommandKeyName = "command" SectionWorkingDirKeyName = "workingdir" + SectionFollowKeyName = "follow" defaultSectionName = "DEFAULT" ) @@ -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, } } diff --git a/core/command.go b/core/command.go index 797ead7..a453f2e 100644 --- a/core/command.go +++ b/core/command.go @@ -6,6 +6,7 @@ const ( type Command struct { Name, Command, WorkingDir string + Follow bool RequiresConfirmation bool }