config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bash       = "bash"
	Zsh        = "zsh"
	Fish       = "fish"
	Powershell = "powershell"
)
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"

	CompletionFlag = "completion"

	// 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"

CurrentValueKey is the key for the current YAML node's value

deprecated

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 slog.Level, format LogFormat)

func LogFormatStrings added in v0.8.0

func LogFormatStrings() []string

LogFormatStrings returns a slice of all String values of the enum

func LogLevelStrings added in v0.8.0

func LogLevelStrings() []string

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  string
	LogFormat string

	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 LogFormat added in v0.8.0

type LogFormat uint8
const (
	FormatAuto LogFormat = iota
	FormatColor
	FormatPlain
	FormatJSON
)

func LogFormatString added in v0.8.0

func LogFormatString(s string) (LogFormat, error)

LogFormatString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LogFormatValues added in v0.8.0

func LogFormatValues() []LogFormat

LogFormatValues returns all values of the enum

func (LogFormat) IsALogFormat added in v0.8.0

func (i LogFormat) IsALogFormat() bool

IsALogFormat returns "true" if the value is listed in the enum definition. "false" otherwise

func (LogFormat) MarshalText added in v0.8.0

func (i LogFormat) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for LogFormat

func (LogFormat) String added in v0.8.0

func (i LogFormat) String() string

func (*LogFormat) UnmarshalText added in v0.8.0

func (i *LogFormat) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for LogFormat

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

V returns the current YAML node value

Deprecated: Use `current` template function instead

func (Vars) Val deprecated added in v0.6.1

func (vars Vars) Val() any

Val returns the current YAML node value

Deprecated: Use `current` template function instead

func (Vars) Value deprecated added in v0.6.1

func (vars Vars) Value() any

Value returns the current YAML node value

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