toolenv

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON[T any](r io.Reader) (*T, error)

ReadJSON decodes all data from the provided reader into the supplied generic type.

func WriteError

func WriteError(w io.Writer, message string, err error) error

WriteError emits a standard error envelope for CLI tools.

func WriteJSON

func WriteJSON(w io.Writer, value any) error

WriteJSON encodes the supplied value as compact JSON to the writer.

Types

type Environment

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

Environment wires together providers and the file processor for standalone tools.

func NewEnvironment

func NewEnvironment() (*Environment, error)

NewEnvironment constructs an Environment with all built-in language providers registered.

func (*Environment) FileProcessor

func (env *Environment) FileProcessor() *core.FileProcessor

FileProcessor returns the configured file processor capable of multi-file operations.

func (*Environment) Provider

func (env *Environment) Provider(language string) (providers.Provider, error)

Provider returns the provider implementation for the requested language.

func (*Environment) Providers

func (env *Environment) Providers() *providers.Registry

Providers exposes the underlying registry for callers that need direct access.

type SourceData

type SourceData struct {
	Code     string
	Path     string
	Perm     os.FileMode
	FromFile bool
}

SourceData encapsulates the resolved source code for single-file tools.

func LoadSource

func LoadSource(source *string, path *string) (*SourceData, error)

LoadSource resolves code from either an inline source field or a filesystem path. Exactly one input must be provided. The function preserves file permissions when reading from disk so callers can write modifications back safely.

Jump to

Keyboard shortcuts

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