Skip to content

Commit

Permalink
feat: Implement option for custom output destinations (#877)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Bestavros <mbestavr@redhat.com>
  • Loading branch information
mbestavros committed Oct 20, 2023
1 parent cee6961 commit ce7592e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Options struct {
SuppressExceptions bool
ShowSkipped bool
JUnitHideMessage bool
File *os.File
}

// The defined output formats represent all of the supported formats
Expand All @@ -37,23 +38,27 @@ const (

// Get returns a type that can render output in the given format.
func Get(format string, options Options) Outputter {
if options.File == nil {
options.File = os.Stdout
}

switch format {
case OutputStandard:
return &Standard{Writer: os.Stdout, NoColor: options.NoColor, SuppressExceptions: options.SuppressExceptions, Tracing: options.Tracing, ShowSkipped: options.ShowSkipped}
return &Standard{Writer: options.File, NoColor: options.NoColor, SuppressExceptions: options.SuppressExceptions, Tracing: options.Tracing, ShowSkipped: options.ShowSkipped}
case OutputJSON:
return NewJSON(os.Stdout)
return NewJSON(options.File)
case OutputTAP:
return NewTAP(os.Stdout)
return NewTAP(options.File)
case OutputTable:
return NewTable(os.Stdout)
return NewTable(options.File)
case OutputJUnit:
return NewJUnit(os.Stdout, options.JUnitHideMessage)
return NewJUnit(options.File, options.JUnitHideMessage)
case OutputGitHub:
return NewGitHub(os.Stdout)
return NewGitHub(options.File)
case OutputAzureDevOps:
return NewAzureDevOps(os.Stdout)
return NewAzureDevOps(options.File)
default:
return NewStandard(os.Stdout)
return NewStandard(options.File)
}
}

Expand Down

0 comments on commit ce7592e

Please sign in to comment.