call

package
v0.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package call provides helpers for managing and executing asynchronous work

 across multiple repositories. Commands for this batch tool shall execute
 `Do(...)` with a Wrapper containing all of the tasks for that command.

 Example:
 	repos := []string{"repo1", "repo2", "repo3"}
		fwrap := Wrap(Exec("git", "status"), Exec("ls"))
		Do(repos, fwrap)

	The above example code calls `git status` followed by `ls` on all three
	provided repositories, executing asynchronously and printing the output
	in order. Console output will block iteratively across the repository
	list to ensure that the output isn't mixed, but the processing of each
	repository's respective tasks is fully parallel in the background.

	The `Exec` CallFunc builder should be sufficient for most commands, but
	custom CallFunc instances can be defined for more complex scenarios. It
	is also possible to define entire `Wrapper` instances if a specific use
	case requires special handling distinct from the default behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(cmd *cobra.Command, repos []string, callFunc CallFunc, handler ...output.Handler)

Do executes the provided CallFunc on each repository, operating asynchronously by default with configurable concurrency limits. Repository aliases are also expanded here to allow for configurable repository grouping. Output formatting can be fully customized by optionally providing one or more OutputHandler functions. Each repository will also be cloned first if it is missing from the local file system.

Types

type CallFunc

type CallFunc func(ctx context.Context, repo string, ch chan<- string) error

CallFunc defines an atomic unit of work on a repository. Output should be sent to the channel, which must remain open. Closing a channel from within the context of a CallFunc will result in a panic.

func Exec

func Exec(command string, arguments ...string) CallFunc

Exec creates a new CallFunc to execute the given command and arguments, streaming Stdout and Stderr to the channel and returning error status.

func Wrap

func Wrap(calls ...CallFunc) CallFunc

Wrap each provided CallFunc into a new one that executes them order before terminating.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL