github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/spec/features/featuremap.go (about) 1 package features 2 3 import ( 4 "github.com/metux/go-metabuild/util/specobj" 5 ) 6 7 type FeatureMap struct { 8 specobj.SpecObj 9 } 10 11 func (fm FeatureMap) IDs() []Key { 12 return fm.Keys() 13 } 14 15 func (fm FeatureMap) All() []Feature { 16 f := []Feature{} 17 for _, k := range fm.Keys() { 18 f = append(f, fm.Get(k)) 19 } 20 return f 21 } 22 23 func (fm FeatureMap) Get(k Key) Feature { 24 return Feature{fm.EntrySpec(k), k} 25 } 26 27 func (fm FeatureMap) Map() map[Key]string { 28 m := make(map[Key]string) 29 for _, k := range fm.Keys() { 30 m[k] = fm.EntryStr(k.Append(KeyEnabled)) 31 } 32 return m 33 } 34 35 func (fm FeatureMap) Init() { 36 for _, k := range fm.Keys() { 37 fm.DefaultPutStr(k.Append(KeyEnabled), "${@@PARENT::default}") 38 } 39 }