diff --git a/cmd/gomote/create.go b/cmd/gomote/create.go index 7ba8a405c6..406f17ea0f 100644 --- a/cmd/gomote/create.go +++ b/cmd/gomote/create.go @@ -144,6 +144,12 @@ func create(args []string) error { fs.Usage = func() { fmt.Fprintln(os.Stderr, "create usage: gomote create [create-opts] ") + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "If there's a valid group specified, new instances are") + fmt.Fprintln(os.Stderr, "automatically added to the group. If the group in") + fmt.Fprintln(os.Stderr, "$GOMOTE_GROUP doesn't exist, and there's no other group") + fmt.Fprintln(os.Stderr, "specified, it will be created and new instances will be") + fmt.Fprintln(os.Stderr, "added to that group.") fs.PrintDefaults() fmt.Fprintln(os.Stderr, "\nValid types:") for _, bt := range builders() { @@ -183,6 +189,12 @@ func create(args []string) error { return err } } + if group == nil && os.Getenv("GOMOTE_GROUP") != "" { + group, err = doCreateGroup(os.Getenv("GOMOTE_GROUP")) + if err != nil { + return err + } + } var tmpOutDir string var tmpOutDirOnce sync.Once diff --git a/cmd/gomote/gomote.go b/cmd/gomote/gomote.go index c50d1435b5..8cfb9d663d 100644 --- a/cmd/gomote/gomote.go +++ b/cmd/gomote/gomote.go @@ -228,6 +228,7 @@ func main() { if err == nil { fmt.Fprintf(os.Stderr, "# Using group %q from GOMOTE_GROUP\n", *groupName) } + // Note that an invalid group in GOMOTE_GROUP is OK. } }