cmd

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cmd provides lazily resolved external commands for iv decoders that shell out (ffmpeg, ffprobe).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Source

func Source(ctx context.Context, r io.Reader, ext string) (string, func(), error)

Source returns a path on disk holding the contents of r, along with a cleanup func. When the decode target is already a file, its path is used as-is and cleanup is a no-op; otherwise the stream is spooled to a temp file with the given extension.

func TempDir

func TempDir(ctx context.Context) (string, func(), error)

TempDir creates a temp directory and returns it with a cleanup func.

Types

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

Cmd is an external command, resolved in $PATH on first use.

func New

func New(name string) *Cmd

New creates a lazily resolved external command.

func (*Cmd) Available

func (c *Cmd) Available() bool

Available reports whether the command is in $PATH.

func (*Cmd) CombinedOutput

func (c *Cmd) CombinedOutput(ctx context.Context, params ...string) ([]byte, error)

CombinedOutput executes the command, returning its combined output.

func (*Cmd) Name

func (c *Cmd) Name() string

Name returns the command name.

func (*Cmd) Path

func (c *Cmd) Path() (string, error)

Path returns the resolved path of the command.

func (*Cmd) Run

func (c *Cmd) Run(ctx context.Context, params ...string) ([]byte, error)

Run executes the command, returning its standard output. Any error includes the leading portion of standard error.

func (*Cmd) Stream added in v0.18.0

func (c *Cmd) Stream(ctx context.Context, f func(io.Reader) error, params ...string) error

Stream runs the command, handing its standard output to f as it is written rather than collecting it first, and returns when f does.

The command is stopped once f returns, so a caller that has read as much as it wants leaves nothing behind blocked on a pipe that nobody is reading -- and what the command made of being stopped, a kill or a broken pipe, is not an error to report. A command that failed while f was reading shows up as the short read f reports instead, and its standard error is put with it.

Jump to

Keyboard shortcuts

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