package env

import "github.com/go-sprout/sprout"

type EnvironmentRegistry struct {
	handler sprout.Handler // Embedding Handler for shared functionality
}

// NewRegistry creates a new instance of env registry.
func NewRegistry() *EnvironmentRegistry {
	return &EnvironmentRegistry{}
}

// UID returns the unique identifier of the registry.
func (or *EnvironmentRegistry) UID() string {
	return "go-sprout/sprout.env"
}

// LinkHandler links the handler to the registry at runtime.
func (or *EnvironmentRegistry) LinkHandler(fh sprout.Handler) error {
	or.handler = fh
	return nil
}

// RegisterFunctions registers all functions of the registry.
func (er *EnvironmentRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error {
	sprout.AddFunction(funcsMap, "env", er.Env)
	sprout.AddFunction(funcsMap, "expandEnv", er.ExpandEnv)
	return nil
}
