Refactored, added comprehensive testing.
All checks were successful
Release / release (push) Successful in 3m17s
All checks were successful
Release / release (push) Successful in 3m17s
This commit is contained in:
32
input/aggregate.go
Normal file
32
input/aggregate.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package input
|
||||
|
||||
// AggregatePrompts combines prompt sources with stdin based on role.
|
||||
func AggregatePrompts(prompts []string, stdin string, role StdinRole) []string {
|
||||
switch role {
|
||||
case StdinAsPrompt:
|
||||
if stdin != "" {
|
||||
return []string{stdin}
|
||||
}
|
||||
return prompts
|
||||
|
||||
case StdinAsPrefixedContent:
|
||||
if stdin != "" {
|
||||
return append(prompts, stdin)
|
||||
}
|
||||
return prompts
|
||||
|
||||
case StdinAsFile:
|
||||
return prompts
|
||||
|
||||
default:
|
||||
return prompts
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFiles combines file sources with stdin based on role.
|
||||
func AggregateFiles(files []FileData, stdin string, role StdinRole) []FileData {
|
||||
if role == StdinAsFile && stdin != "" {
|
||||
return append([]FileData{{Path: "input", Content: stdin}}, files...)
|
||||
}
|
||||
return files
|
||||
}
|
||||
Reference in New Issue
Block a user