tools

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

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

CommandRunner implements the Runner interface using os/exec.

func (*CommandRunner) Check

func (r *CommandRunner) Check(ctx context.Context) error

Check verifies the tool exists and is executable.

func (*CommandRunner) Run

func (r *CommandRunner) Run(ctx context.Context, args ...string) ([]byte, []byte, error)

Run executes the tool with given arguments.

func (*CommandRunner) RunWithInput

func (r *CommandRunner) RunWithInput(ctx context.Context, input []byte, args ...string) ([]byte, []byte, error)

RunWithInput executes the tool with stdin input.

func (*CommandRunner) ToolName

func (r *CommandRunner) ToolName() string

ToolName returns the name of the tool.

func (*CommandRunner) ToolPath

func (r *CommandRunner) ToolPath() string

ToolPath returns the path to the tool.

type Runner

type Runner interface {
	// Check verifies the tool exists and is executable.
	Check(ctx context.Context) error

	// Run executes the tool with given arguments.
	Run(ctx context.Context, args ...string) (stdout []byte, stderr []byte, err error)

	// RunWithInput executes the tool with stdin input.
	RunWithInput(ctx context.Context, input []byte, args ...string) (stdout []byte, stderr []byte, err error)

	// ToolName returns the name of the tool (e.g., "magika", "exiftool").
	ToolName() string

	// ToolPath returns the configured path to the tool.
	ToolPath() string
}

Runner defines an interface for executing external command-line tools.

func NewExiftoolRunner

func NewExiftoolRunner(customPath string) (Runner, error)

NewExiftoolRunner creates a new Runner for the ExifTool tool.

func NewFileRunner

func NewFileRunner(customPath string) (Runner, error)

NewFileRunner creates a new Runner for the file command.

func NewJdupesRunner

func NewJdupesRunner(customPath string) (Runner, error)

NewJdupesRunner creates a new Runner for the jdupes tool.

func NewMagikaRunner

func NewMagikaRunner(customPath string) (Runner, error)

NewMagikaRunner creates a new Runner for the Magika tool.

func NewRunner

func NewRunner(name, path string) (Runner, error)

NewRunner creates a new CommandRunner for the specified tool. If path is empty, it attempts to locate the tool on the PATH.

Jump to

Keyboard shortcuts

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