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:
26
input/role.go
Normal file
26
input/role.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package input
|
||||
|
||||
import "git.wisehodl.dev/jay/aicli/config"
|
||||
|
||||
// DetermineRole decides how stdin content participates in the query based on
|
||||
// flags and stdin presence. Per spec §7 rules.
|
||||
func DetermineRole(cfg config.ConfigData, hasStdin bool) StdinRole {
|
||||
if !hasStdin {
|
||||
return StdinAsPrompt // unused, but set for consistency
|
||||
}
|
||||
|
||||
// Explicit -F flag forces stdin as file
|
||||
if cfg.StdinAsFile {
|
||||
return StdinAsFile
|
||||
}
|
||||
|
||||
// Any explicit prompt flag (-p or -pf) makes stdin prefixed content
|
||||
hasExplicitPrompt := len(cfg.PromptFlags) > 0 || len(cfg.PromptPaths) > 0
|
||||
|
||||
if hasExplicitPrompt {
|
||||
return StdinAsPrefixedContent
|
||||
}
|
||||
|
||||
// Default: stdin replaces any default prompt
|
||||
return StdinAsPrompt
|
||||
}
|
||||
Reference in New Issue
Block a user