config

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarFlag = "var"

	InplaceFlag         = "inplace"
	PrefixFlag          = "prefix"
	LeftDelimFlag       = "left-delim"
	RightDelimFlag      = "right-delim"
	IndentFlag          = "indent"
	StripFlag           = "strip"
	NoSourceCommentFlag = "no-source-comment"

	IgnoreUnsetErrorsFlag    = "ignore-unset-errors"
	IgnoreTemplateErrorsFlag = "ignore-template-errors"

	LogLevelFlag  = "log-level"
	LogFormatFlag = "log-format"

	// Deprecated: Replaced by VarFlag.
	ValueFlag = "value"
	// Deprecated: Removed. Yampl will always recurse if a given path is a directory.
	RecursiveFlag = "recursive"
	// Deprecated: Replaced by IgnoreUnsetErrorsFlag and IgnoreTemplateErrorsFlag.
	FailFlag = "fail"
)
View Source
const CurrentValueKey = "Value"

Deprecated: Use `current` template function instead.

View Source
const EnvPrefix = "YAMPL_"

Variables

View Source
var ErrCmdMissingConfig = errors.New("config missing from command context")

Functions

func BoolCompletion added in v0.6.0

func BoolCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

func EnvName added in v0.6.0

func EnvName(name string) string

func InitLog added in v0.8.0

func InitLog(w io.Writer, level slogx.Level, format slogx.Format)

func WithContext added in v0.4.0

func WithContext(ctx context.Context, conf *Config) context.Context

Types

type Config

type Config struct {
	Vars Vars

	Inplace         bool
	Prefix          string
	LeftDelim       string
	RightDelim      string
	Indent          int
	Strip           bool
	NoSourceComment bool

	IgnoreUnsetErrors    bool
	IgnoreTemplateErrors bool

	LogLevel  slogx.Level
	LogFormat slogx.Format

	Completion string
	// contains filtered or unexported fields
}

func FromContext added in v0.4.0

func FromContext(ctx context.Context) (*Config, bool)

func Load added in v0.8.0

func Load(cmd *cobra.Command) (*Config, error)

func New

func New() *Config

func (*Config) InitLog added in v0.8.0

func (c *Config) InitLog(w io.Writer)

func (*Config) RegisterCompletions added in v0.6.0

func (c *Config) RegisterCompletions(cmd *cobra.Command)

func (*Config) RegisterFlags added in v0.6.0

func (c *Config) RegisterFlags(cmd *cobra.Command)

type DeprecatedWriter added in v0.6.1

type DeprecatedWriter struct{}

func (DeprecatedWriter) Write added in v0.6.1

func (d DeprecatedWriter) Write(b []byte) (int, error)

type Vars added in v0.6.1

type Vars map[string]any

func (Vars) Fill added in v0.6.1

func (vars Vars) Fill(src map[string]string)

func (Vars) SetNested added in v0.6.1

func (vars Vars) SetNested(v any, k ...string)

func (Vars) V deprecated added in v0.6.1

func (vars Vars) V() any

Deprecated: Use `current` template function instead.

func (Vars) Val deprecated added in v0.6.1

func (vars Vars) Val() any

Deprecated: Use `current` template function instead.

func (Vars) Value deprecated added in v0.6.1

func (vars Vars) Value() any

Deprecated: Use `current` template function instead.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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