{"modulePath":"github.com/openkaiden/kdn","version":"v0.19.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package exec\n\nPackage exec provides an abstraction for executing openshell commands.\n\n## Types\n\n```go\ntype Executor interface {\n\t// BinaryPath returns the path to the openshell binary.\n\tBinaryPath() string\n\n\t// Run executes an openshell command, writing stdout and stderr to the provided writers.\n\tRun(ctx context.Context, stdout, stderr io.Writer, args ...string) error\n\n\t// Output executes an openshell command and returns its standard output.\n\tOutput(ctx context.Context, stderr io.Writer, args ...string) ([]byte, error)\n\n\t// RunInteractive executes an openshell command with stdin/stdout/stderr connected to the terminal.\n\tRunInteractive(ctx context.Context, args ...string) error\n}\n```\nExecutor provides an interface for executing openshell commands.\n\n```go\nfunc New(binaryPath string) Executor\n```\nNew creates a new Executor instance that runs the given binary.\n\n```go\ntype FakeExecutor struct {\n\t// RunFunc is called when Run is invoked. If nil, Run returns nil.\n\tRunFunc func(ctx context.Context, args ...string) error\n\n\t// OutputFunc is called when Output is invoked. If nil, Output returns empty bytes.\n\tOutputFunc func(ctx context.Context, args ...string) ([]byte, error)\n\n\t// RunInteractiveFunc is called when RunInteractive is invoked. If nil, RunInteractive returns nil.\n\tRunInteractiveFunc func(ctx context.Context, args ...string) error\n\n\t// RunCalls tracks all calls to Run with their arguments.\n\tRunCalls [][]string\n\n\t// OutputCalls tracks all calls to Output with their arguments.\n\tOutputCalls [][]string\n\n\t// RunInteractiveCalls tracks all calls to RunInteractive with their arguments.\n\tRunInteractiveCalls [][]string\n}\n```\nFakeExecutor is a fake implementation of Executor for testing.\n\n```go\nfunc NewFake() *FakeExecutor\n```\nNewFake creates a new FakeExecutor.\n\n```go\nfunc (f *FakeExecutor) BinaryPath() string\n```\nBinaryPath is the path returned by BinaryPath(). Set in tests if needed.\n\n```go\nfunc (f *FakeExecutor) Output(ctx context.Context, stderr io.Writer, args ...string) ([]byte, error)\n```\nOutput executes the OutputFunc if set, otherwise returns empty bytes.\n\n```go\nfunc (f *FakeExecutor) Run(ctx context.Context, stdout, stderr io.Writer, args ...string) error\n```\nRun executes the RunFunc if set, otherwise returns nil.\n\n```go\nfunc (f *FakeExecutor) RunInteractive(ctx context.Context, args ...string) error\n```\nRunInteractive executes the RunInteractiveFunc if set, otherwise returns nil.\n\n","path":"github.com/openkaiden/kdn/pkg/runtime/openshell/exec","name":"exec","synopsis":"Package exec provides an abstraction for executing openshell commands.","isRedistributable":true}
