parseCommentMemoryConfigValue handles comment-memory configuration values.
(rawConfig any)
| 24 | |
| 25 | // parseCommentMemoryConfigValue handles comment-memory configuration values. |
| 26 | func (c *Compiler) parseCommentMemoryConfigValue(rawConfig any) *CommentMemoryConfig { |
| 27 | switch v := rawConfig.(type) { |
| 28 | case nil: |
| 29 | commentMemoryLog.Print("comment-memory explicitly disabled with null") |
| 30 | return nil |
| 31 | case bool: |
| 32 | if !v { |
| 33 | commentMemoryLog.Print("comment-memory explicitly disabled with false") |
| 34 | return nil |
| 35 | } |
| 36 | return &CommentMemoryConfig{ |
| 37 | BaseSafeOutputConfig: BaseSafeOutputConfig{ |
| 38 | Max: defaultIntStr(1), |
| 39 | }, |
| 40 | MemoryID: "default", |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | commentMemoryLog.Print("Parsing comment-memory configuration") |
| 45 | |
| 46 | configData, _ := rawConfig.(map[string]any) |
| 47 | if err := preprocessIntFieldAsString(configData, "max", commentMemoryLog); err != nil { |
| 48 | commentMemoryLog.Printf("Invalid max value: %v", err) |
| 49 | return nil |
| 50 | } |
| 51 | if err := preprocessBoolFieldAsString(configData, "footer", commentMemoryLog); err != nil { |
| 52 | commentMemoryLog.Printf("Invalid footer value: %v", err) |
| 53 | return nil |
| 54 | } |
| 55 | |
| 56 | var config CommentMemoryConfig |
| 57 | normalizedOutputMap := map[string]any{"comment-memory": rawConfig} |
| 58 | if err := unmarshalConfig(normalizedOutputMap, "comment-memory", &config, commentMemoryLog); err != nil { |
| 59 | commentMemoryLog.Printf("Failed to unmarshal config: %v", err) |
| 60 | config = CommentMemoryConfig{} |
| 61 | } |
| 62 | |
| 63 | if config.Max == nil { |
| 64 | config.Max = defaultIntStr(1) |
| 65 | } |
| 66 | if config.MemoryID == "" { |
| 67 | config.MemoryID = "default" |
| 68 | } |
| 69 | |
| 70 | return &config |
| 71 | } |
no test coverage detected