github.com/devster/tarreleaser@v0.0.0-20221207180803-c608f4eb8918/pkg/pipe/output/output.go (about)

     1  package output
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/devster/tarreleaser/pkg/context"
     6  	"github.com/devster/tarreleaser/pkg/tmpl"
     7  )
     8  
     9  type Pipe struct{}
    10  
    11  func (Pipe) String() string {
    12  	return ""
    13  }
    14  
    15  func (Pipe) Default(ctx *context.Context) error {
    16  	return nil
    17  }
    18  
    19  func (Pipe) Run(ctx *context.Context) error {
    20  	if ctx.OutputFormat == "" {
    21  		return nil
    22  	}
    23  
    24  	output, err := tmpl.New(ctx).Apply(ctx.OutputFormat)
    25  	if err != nil {
    26  		return fmt.Errorf("output format error: %s", err.Error())
    27  	}
    28  
    29  	fmt.Print(output)
    30  
    31  	return nil
    32  }