Skip to content

🌟 ExecAll ​

Runs all available vendor binaries in the project and returns a mapping of each binary to its output. Internally it first calls ExecWithList to obtain the list, then runs each via Exec.

When to use ​

Use it when you need to run the same set of arguments against all vendor bin tools in bulk (for example, printing version numbers or performing batch self-checks).

Signature ​

go
func (c *Composer) ExecAll(args ...string) (map[string]string, error)

Parameters ​

ParameterTypeDescription
args...stringArgument list forwarded to each binary

Return value ​

Return valueTypeDescription
First return valuemap[string]stringKey is the binary name, value is the stdout output (on failure, Error: ...)
Second return valueerrorReturned when retrieving the binary list fails

Single failure does not abort

When a binary execution fails, it does not abort the overall flow; its result is written as Error: <err> into the corresponding key.

Example ​

go
package main

import (
	"fmt"
	"log"

	"github.com/scagogogo/composer-skills/pkg/composer"
)

func main() {
	comp, err := composer.New(composer.DefaultOptions())
	if err != nil {
		log.Fatalf("initialization failed: %v", err)
	}

	results, err := comp.ExecAll("--version")
	if err != nil {
		log.Fatalf("batch execution failed: %v", err)
	}

	for name, output := range results {
		fmt.Printf("=== %s ===\n%s\n", name, output)
	}
}

Advanced ​

  • The candidate list comes from ExecWithList; you can call it first to confirm the scope.
  • To execute a single binary, use Exec or ExecPHP.
  • This method does not return an error for individual failures; it only returns an error when the list cannot be retrieved.

Released under the MIT License