Documentation
¶
Overview ¶
Package executable provides utilities for working with executable files and their versions. It defines structures and methods for executing commands on files and extracting information using command strategies and regular expression patterns.
The core components include: - Executable: Represents a file with version information and allows command execution. - Parser: Defines patterns and strategies to parse strings from command outputs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatch = errors.New("no match found")
ErrNoMatch is returned when no match is found in the output.
Functions ¶
This section is empty.
Types ¶
type Executable ¶
type Executable string
Executable represents the path to an executable.
func New ¶
func New(paths ...string) Executable
New creates a new Executable instance from the provided paths.
func (Executable) Command ¶
Command runs the specified command arguments by passing them to the executable. It returns the output of the command as a trimmed string and any error encountered during execution.
func (Executable) Parse ¶
func (e Executable) Parse(parser *Parser) (string, error)
Parse attempts to parse the output of the executable using the provided Parser object. It iterates over each command defined in the Parser and returns the first successful match.
func (Executable) String ¶ added in v0.0.13
func (e Executable) String() string
String returns the executable path as a string.
type Parser ¶
type Parser struct {
// Patterns are regex patterns used to match strings in command output.
Patterns []string
// Commands are command strategies to be executed for extraction.
Commands []string
}
Parser provides functionality for parsing strings from an output using regex patterns.