github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/cmd/syft/internal/options/format_cyclonedx_json.go (about)

     1  package options
     2  
     3  import (
     4  	"github.com/anchore/syft/syft/format/cyclonedxjson"
     5  )
     6  
     7  type FormatCyclonedxJSON struct {
     8  	Pretty *bool `yaml:"pretty" json:"pretty" mapstructure:"pretty"`
     9  }
    10  
    11  func DefaultFormatCyclonedxJSON() FormatCyclonedxJSON {
    12  	return FormatCyclonedxJSON{}
    13  }
    14  
    15  func (o FormatCyclonedxJSON) config(version string) cyclonedxjson.EncoderConfig {
    16  	var pretty bool
    17  	if o.Pretty != nil {
    18  		pretty = *o.Pretty
    19  	}
    20  	return cyclonedxjson.EncoderConfig{
    21  		Version: version,
    22  		Pretty:  pretty,
    23  	}
    24  }