Skip to content

Commit

Permalink
Merge pull request #698 from thedadams/no-fields-prompt
Browse files Browse the repository at this point in the history
feat: include fields in prompt only when there are fields
  • Loading branch information
ibuildthecloud authored Aug 3, 2024
2 parents d0092f9 + 0e6722e commit 24b1f24
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ func SysPrompt(ctx context.Context, envs []string, input string, _ chan<- string

for _, env := range envs {
if url, ok := strings.CutPrefix(env, types.PromptURLEnvVar+"="); ok {
var fields []string
if params.Fields != "" {
fields = strings.Split(params.Fields, ",")
}
httpPrompt := types.Prompt{
Message: params.Message,
Fields: strings.Split(params.Fields, ","),
Fields: fields,
Sensitive: params.Sensitive == "true",
}
return sysPromptHTTP(ctx, envs, url, httpPrompt)
Expand All @@ -76,7 +80,7 @@ func SysPrompt(ctx context.Context, envs []string, input string, _ chan<- string
func sysPrompt(ctx context.Context, req types.Prompt) (_ string, err error) {
defer context2.GetPauseFuncFromCtx(ctx)()()

if req.Message != "" && len(req.Fields) == 1 && strings.TrimSpace(req.Fields[0]) == "" {
if req.Message != "" && len(req.Fields) == 0 {
var errs []error
_, err := fmt.Fprintln(os.Stderr, req.Message)
errs = append(errs, err)
Expand Down

0 comments on commit 24b1f24

Please sign in to comment.