on main help sign in
refactor: simplify code with `cmp.Or`
0ca5de0Andrey Nering
internal/agent/prompt/prompt.go+3−8
@@ -1,6 +1,7 @@
1package prompt
1package prompt
2
2
3import (
3import (
4+ "cmp"
4 "context"
5 "context"
5 "fmt"
6 "fmt"
6 "os"
7 "os"
@@ -146,14 +147,8 @@ func expandPath(path string, cfg config.Config) string {
146}
147}
147
148
148func (p *Prompt) promptData(ctx context.Context, provider, model string, cfg config.Config) (PromptDat, error) {
149func (p *Prompt) promptData(ctx context.Context, provider, model string, cfg config.Config) (PromptDat, error) {
149− workingDir := cfg.WorkingDir()
150+ workingDir := cmp.Or(p.workingDir, cfg.WorkingDir())
150− if p.workingDir != "" {
151− workingDir = p.workingDir
152− }
153− platform := runtime.GOOS
151+ platform := cmp.Or(p.platform, runtime.GOOS)
154− if p.platform != "" {
155− platform = p.platform
156− }
157
152
158 files := map[string][]ContextFile{}
153 files := map[string][]ContextFile{}
159
154