Skip to content

Commit

Permalink
Rename CommandResponse to CommandOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvelabs committed Dec 22, 2022
1 parent 298fe05 commit ee3f443
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
16 changes: 9 additions & 7 deletions internal/stylist/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ func (c *Command) executeBatch(ctx context.Context, paths []string) ([]*Result,
return nil, err
}

resp := &CommandResponse{
Out: stdout,
Err: stderr,
ExitCode: cmd.ProcessState.ExitCode(),
}
return NewOutputParser(c.Output).Parse(resp)
return NewOutputParser(c.Output).Parse(
&CommandOutput{
Out: stdout,
Err: stderr,
ExitCode: cmd.ProcessState.ExitCode(),
},
)
}

func (c *Command) parallelism() int {
Expand Down Expand Up @@ -150,7 +151,8 @@ func (c *Command) partition(paths []string) [][]string {
return batches
}

type CommandResponse struct {
// CommandOutput contains the result of a single command invocation.
type CommandOutput struct {
Out io.Reader
Err io.Reader
ExitCode int
Expand Down
20 changes: 10 additions & 10 deletions internal/stylist/output_parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

// OutputParser is the interface that wraps the Parse method.
//
// Parse parses a command response into a slice of results.
// Parse parses command output into a slice of results.
type OutputParser interface {
Parse(response *CommandResponse) ([]*Result, error)
Parse(output *CommandOutput) ([]*Result, error)
}

// NewOutputParser returns the appropriate parser for the given output type.
Expand All @@ -35,8 +35,8 @@ func NewOutputParser(ot OutputType) OutputParser { //nolint:ireturn
type JSONOutputParser struct {
}

// Parse parses a command response into a slice of results.
func (p *JSONOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
// Parse parses command output into a slice of results.
func (p *JSONOutputParser) Parse(output *CommandOutput) ([]*Result, error) {
return nil, nil
}

Expand All @@ -48,8 +48,8 @@ func (p *JSONOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
type NoneOutputParser struct {
}

// Parse parses a command response into a slice of results.
func (p *NoneOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
// Parse parses command output into a slice of results.
func (p *NoneOutputParser) Parse(output *CommandOutput) ([]*Result, error) {
return nil, nil
}

Expand All @@ -61,8 +61,8 @@ func (p *NoneOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
type RegexpOutputParser struct {
}

// Parse parses a command response into a slice of results.
func (p *RegexpOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
// Parse parses command output into a slice of results.
func (p *RegexpOutputParser) Parse(output *CommandOutput) ([]*Result, error) {
return nil, nil
}

Expand All @@ -74,7 +74,7 @@ func (p *RegexpOutputParser) Parse(response *CommandResponse) ([]*Result, error)
type SarifOutputParser struct {
}

// Parse parses a command response into a slice of results.
func (p *SarifOutputParser) Parse(response *CommandResponse) ([]*Result, error) {
// Parse parses command output into a slice of results.
func (p *SarifOutputParser) Parse(output *CommandOutput) ([]*Result, error) {
return nil, nil
}

0 comments on commit ee3f443

Please sign in to comment.