diff --git a/config.go b/config.go index 08166ce..12f9c45 100644 --- a/config.go +++ b/config.go @@ -23,5 +23,10 @@ type Mapping struct { } type Config struct { - Mappings []Mapping `toml:"mappings"` + Mappings []Mapping `toml:"mappings"` + Settings GenSetting `toml:"settings"` +} + +type GenSetting struct { + Style string `toml:"style"` } diff --git a/main.go b/main.go index ac12dba..c84f11d 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,8 @@ func main() { Send() } + log.Print(cfg) + groupedMappings := groupMappings(cfg.Mappings) var batchWork [][]work @@ -100,7 +102,11 @@ func main() { var endResult []File for _, groupedWork := range batchWork { - result, err := Process(groupedWork) + g := Generator{ + style: cfg.Settings.Style, + } + + result, err := g.Process(groupedWork) if err != nil { log.Fatal(). Err(err). @@ -137,9 +143,8 @@ func Usage() { flag.PrintDefaults() } -func Process(groupedWork []work) (File, error) { +func (g *Generator) Process(groupedWork []work) (File, error) { var result File - g := Generator{} if len(groupedWork) == 0 { return result, errNoWork @@ -171,7 +176,8 @@ func groupMappings(mappings []Mapping) map[string][]Mapping { } type Generator struct { - buf bytes.Buffer + buf bytes.Buffer + style string } func (g *Generator) Printf(format string, args ...any) { diff --git a/main_test.go b/main_test.go index 057404b..a5e2ee9 100644 --- a/main_test.go +++ b/main_test.go @@ -350,7 +350,8 @@ func TestProcess(t *testing.T) { } t.Run("No work", func(t *testing.T) { - _, err := Process(groupedWork) + g := Generator{} + _, err := g.Process(groupedWork) assert.Equal(t, errNoWork, err) }) @@ -396,7 +397,8 @@ func TestProcess(t *testing.T) { w = generateWorkFromSrcs(code2, "T", code1, "S") groupedWork = append(groupedWork, w) - f, err := Process(groupedWork) + g := Generator{} + f, err := g.Process(groupedWork) assert.NoError(t, err) assert.Equal(t, string(formattedExpectedOutput), string(f.Buf)) }) diff --git a/testdata/km.toml b/testdata/km.toml index 64dc856..18a5649 100644 --- a/testdata/km.toml +++ b/testdata/km.toml @@ -1,3 +1,6 @@ +[settings] +style="default" + [[mappings]] [mappings.settings] override=true