go_sysutils/auger/funcs_augflags.go
brent saner c0c924b75a
v1.3.0
ADDED:
* auger, some convenience funcs around Augeas.
2024-06-20 05:26:56 -04:00

42 lines
865 B
Go

package auger
import (
`honnef.co/go/augeas`
)
// Eval returns an evaluated set of flags.
func (a *AugFlags) Eval() (augFlags augeas.Flag) {
augFlags = augeas.None
if a.Backup != nil && *a.Backup {
augFlags |= augeas.SaveBackup
}
if a.NewFile != nil && *a.NewFile {
augFlags |= augeas.SaveNewFile
}
if a.TypeCheck != nil && *a.TypeCheck {
augFlags |= augeas.TypeCheck
}
if a.NoDfltModLoad != nil && *a.NoDfltModLoad {
augFlags |= augeas.NoModlAutoload
}
if a.DryRun != nil && *a.DryRun {
augFlags |= augeas.SaveNoop
}
if a.NoTree != nil && *a.NoTree {
augFlags |= augeas.NoLoad
}
if a.NoAutoModLoad != nil && *a.NoAutoModLoad {
augFlags |= augeas.NoModlAutoload
}
if a.EnableSpan != nil && *a.EnableSpan {
augFlags |= augeas.EnableSpan
}
if a.NoErrClose != nil && *a.NoErrClose {
augFlags |= augeas.NoErrClose
}
return
}