cmd

package
v0.0.0-...-785df0d Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cmd contains helpers that abstract away the chore of starting new processes, tracking their lifetime, inspecting their output, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCommand

func RunCommand(ctx context.Context, path string, args []string, pf func(string) bool) (bool, error)

RunCommand starts a new process and waits until either its completion, or until the supplied predicate function pf returns true. The function is called for each line produced by the new process.

The returned boolean value equals the last value returned by pf.

The process will be killed both in the event the context is cancelled, and when expectedOutput is found.

func TerminateIfFound

func TerminateIfFound(needle string, logf func(string)) func(string) bool

TerminateIfFound creates RunCommand predicates that instantly terminate program execution in the event the given string is found in any line produced. RunCommand will return true, if the string searched for was found, and false otherwise. If logf isn't nil, it will be called whenever a new line is received.

func WaitUntilCompletion

func WaitUntilCompletion(logf func(string)) func(string) bool

WaitUntilCompletion creates a RunCommand predicate that will make it wait for the process to exit on its own. If logf isn't nil, it will be called whenever a new line is received.

Types

This section is empty.

Jump to

Keyboard shortcuts

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