watcher

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The default value of the time in milliseconds that elapses between each time the fs events are polled (and the handlers triggered)
	DefaultPollIntervalMs = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandParams

type CommandParams struct {
	FileBase string
	FileAbs  string
	FileDir  string
}

Values that will be replaced into a command

func NewCommandParams

func NewCommandParams(fileName string) (CommandParams, error)

type Config

type Config struct {
	// The directories that will be watched for file events
	Directories []string `json:"directories"`
	// The time in milliseconds that elapses between each time the fs events are polled (and the handlers triggered)
	PollIntervalMs uint `json:"pollIntervalMs"`
	// The handlers that will listen for file events
	Handlers []FileHandlerConfig `json:"handlers"`
}

func (*Config) FillInDefaults

func (self *Config) FillInDefaults()

Set the values that were omitted to their default values

type FileHandler

type FileHandler interface {
	FileHandlerTrigger

	Execute(filePath string) error
}

func NewFileHandler

func NewFileHandler(config FileHandlerConfig) (FileHandler, error)

type FileHandlerConfig

type FileHandlerConfig struct {
	// The name of this handler
	Name string `json:"name"`
	// The command that will be executed when this handler is triggered
	Command []string `json:"command"`
	// A list of extensions that will trigger this handler
	Extensions []string `json:"extensions"`
	// A list of files that will be watched for changes
	Files []string `json:"files"`
	// A regex that will trigger this handler
	Regex string `json:"regex"`
	// Wether stdout of the command should be written to stdout
	PrintStdOut bool `json:"printStdOut"`
	// Wether stderr of the command should be written to stderr
	PrintStdErr bool `json:"printStdErr"`
}

Configuration for a file handler

func (*FileHandlerConfig) FillInDefaults

func (self *FileHandlerConfig) FillInDefaults()

type FileHandlerTrigger

type FileHandlerTrigger interface {
	IsTriggeredBy(filePath string) bool
}

type Watcher

type Watcher interface {
	Start() error
	Stop() error
}

func NewWatcher

func NewWatcher(config Config) (Watcher, error)

Jump to

Keyboard shortcuts

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