Permalink
Browse files

support for all subcommand args in launch agent

  • Loading branch information...
justone committed Feb 14, 2016
1 parent b653865 commit 76abcfaadace2735259cedf9502a0173c9905c5f
Showing with 12 additions and 14 deletions.
  1. +6 −10 introducer.go
  2. +3 −1 main.go
  3. +3 −3 osx.go
View
@@ -51,17 +51,13 @@ func (x *IntroducerCommand) Execute(args []string) error {
}
if len(introducerCommand.OSX) > 0 {
// capture existing args so they are reflected in the runner
args := []string{"introducer"}
if introducerCommand.PersistKey {
args = append(args, "-p")
}
if len(introducerCommand.Name) > 0 {
args = append(args, "-n", introducerCommand.Name)
filteredArgs := make([]string, 0)
for _, arg := range originalArgs[1:] {
if !(strings.HasPrefix(arg, "-x=") || strings.HasPrefix(arg, "--osx=")) {
filteredArgs = append(filteredArgs, arg)
}
}
return handleOSXCommand(bus, introducerCommand.OSX, "introducer", args)
return handleOSXCommand(bus, introducerCommand.OSX, "introducer", filteredArgs)
} else {
logrus.Debugf("calling GetConnection")
conn, err := bus.ConnectIntroducer(name)
View
@@ -36,6 +36,7 @@ func (f *SyslogFormatter) Format(entry *logrus.Entry) ([]byte, error) {
var globalOptions GlobalOptions
var parser = flags.NewParser(&globalOptions, flags.Default)
var originalArgs []string
func main() {
@@ -64,7 +65,8 @@ func main() {
}
}
if _, err := parser.Parse(); err != nil {
originalArgs = os.Args
if _, err := parser.ParseArgs(os.Args); err != nil {
os.Exit(1)
}
}
View
6 osx.go
@@ -13,14 +13,14 @@ import (
"github.com/kardianos/osext"
)
func handleOSXCommand(bus *pmb.PMB, command string, jobName string, arguments []string) error {
func handleOSXCommand(bus *pmb.PMB, command string, subcommand string, arguments []string) error {
var err error
logrus.Debugf("Handling %s with args of %s", command, arguments)
// launch agent name
agentName := fmt.Sprintf("org.endot.pmb.%s", jobName)
agentName := fmt.Sprintf("org.endot.pmb.%s", subcommand)
logrus.Debugf("Name of launchagent: %s", agentName)
// figure out launch agent config path
@@ -56,7 +56,7 @@ restart - Restarts agent via launchctl.
configure - This will configure the agent, but not start it.
unconfigure - This will remove the agent configuration.
`, fmt.Sprintf("pmb %s", arguments))
`, fmt.Sprintf("pmb %s", subcommand))
case "restart":
err = configure(launchAgentFile, generateLaunchConfig(launchData))

0 comments on commit 76abcfa

Please sign in to comment.