file_replace

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package file_replace implements the file_replace action handler.

The file_replace action performs in-place text replacement in files with support for: - Literal and regex-based pattern matching - Limited or unlimited replacements (count parameter) - Multiline and case-insensitive modes - Atomic writes (temp file + rename) - Backup creation before modification - Idempotency (no change if pattern doesn't match or already replaced)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct{}

Handler implements the Handler interface for file_replace actions.

func (*Handler) DryRun

func (h *Handler) DryRun(ctx actions.Context, step *config.Step) error

DryRun logs what would happen without making changes.

func (*Handler) Execute

func (h *Handler) Execute(ctx actions.Context, step *config.Step) (actions.Result, error)

Execute runs the file_replace action.

func (*Handler) Metadata

func (h *Handler) Metadata() actions.ActionMetadata

Metadata returns metadata about the file_replace action.

func (*Handler) Run

func (h *Handler) Run(ctx actions.Context, step *config.Step) (actions.Result, error)

Run is the Spec 16 unified entry point. Performs the regex replacement in memory once and either reports the predicted change (ModePlan) or commits it atomically (ModeExecute). Drift between plan preview and real execution is impossible because both modes compute the same `newContent` and compare against the same on-disk content.

func (*Handler) Validate

func (h *Handler) Validate(step *config.Step) error

Validate checks if the file_replace configuration is valid.

Jump to

Keyboard shortcuts

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