Skip to content

Commit

Permalink
feat: add WithOutput API (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani authored Apr 29, 2024
1 parent f922e26 commit 147e30b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion form.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package huh

import (
"errors"
"io"
"os"

"github.com/charmbracelet/bubbles/help"
Expand Down Expand Up @@ -62,6 +63,7 @@ type Form struct {
theme *Theme
keymap *KeyMap
teaOptions []tea.ProgramOption
output io.Writer
}

// NewForm returns a form with the given groups and default themes and
Expand Down Expand Up @@ -285,7 +287,14 @@ func (f *Form) WithHeight(height int) *Form {
return f
}

// WithProgramOptions sets the tea options of thea form.
// WithOutput sets the io.Writer to output the form.
func (f *Form) WithOutput(w io.Writer) *Form {
f.output = w
f.teaOptions = append(f.teaOptions, tea.WithOutput(w))
return f
}

// WithProgramOptions sets the tea options of the form.
func (f *Form) WithProgramOptions(opts ...tea.ProgramOption) *Form {
f.teaOptions = opts
return f
Expand Down

0 comments on commit 147e30b

Please sign in to comment.