Skip to content

Commit

Permalink
feat: use OutputOption
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jan 31, 2023
1 parent bb31c0c commit 925ea91
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type File interface {
Fd() uintptr
}

// OutputOption sets an option on Output.
type OutputOption = func(*Output)

// Output is a terminal output.
type Output struct {
Profile
Expand Down Expand Up @@ -52,7 +55,7 @@ func DefaultOutput() *Output {
}

// NewOutput returns a new Output for the given file descriptor.
func NewOutput(tty io.Writer, opts ...func(*Output)) *Output {
func NewOutput(tty io.Writer, opts ...OutputOption) *Output {
o := &Output{
tty: tty,
environ: &osEnviron{},
Expand All @@ -77,22 +80,22 @@ func NewOutput(tty io.Writer, opts ...func(*Output)) *Output {
}

// WithEnvironment returns a new Output for the given environment.
func WithEnvironment(environ Environ) func(*Output) {
func WithEnvironment(environ Environ) OutputOption {
return func(o *Output) {
o.environ = environ
}
}

// WithProfile returns a new Output for the given profile.
func WithProfile(profile Profile) func(*Output) {
func WithProfile(profile Profile) OutputOption {
return func(o *Output) {
o.Profile = profile
}
}

// WithColorCache returns a new Output with fore- and background color values
// pre-fetched and cached.
func WithColorCache(v bool) func(*Output) {
func WithColorCache(v bool) OutputOption {
return func(o *Output) {
o.cache = v

Expand Down

0 comments on commit 925ea91

Please sign in to comment.