output

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusListener

func StatusListener(o Output, m *module.Module) license.StatusListener

StatusListener returns a license.StatusListener implementation for a single module to route to an Output implementation.

The caller must still call Start and Finish appropriately on the Output while using this StatusListener.

Types

type CSVOutput

type CSVOutput struct {
	Path   string
	Config *config.Config

	sync.Mutex
	// contains filtered or unexported fields
}

func (*CSVOutput) Close

func (c *CSVOutput) Close() error

func (*CSVOutput) Finish

func (c *CSVOutput) Finish(
	m *module.Module,
	l *license.License,
	err error)

func (*CSVOutput) Start

func (c *CSVOutput) Start(m *module.Module)

func (*CSVOutput) Update

func (c *CSVOutput) Update(
	m *module.Module,
	t license.StatusType, msg string)

type MultiOutput

type MultiOutput struct {
	Outputs []Output
}

MultiOutput calls the functions of multiple Output implementations.

func (*MultiOutput) Close

func (o *MultiOutput) Close() error

Close implements Output

func (*MultiOutput) Finish

func (o *MultiOutput) Finish(m *module.Module, l *license.License, err error)

Finish implements Output

func (*MultiOutput) Start

func (o *MultiOutput) Start(m *module.Module)

Start implements Output

func (*MultiOutput) Update

func (o *MultiOutput) Update(m *module.Module, t license.StatusType, msg string)

Update implements Output

type Output

type Output interface {
	// Start is called when the license lookup for a module is started.
	Start(*module.Module)

	// Update is called for each status update during the license lookup.
	Update(*module.Module, license.StatusType, string)

	// Finish is called when a module license lookup is complete with
	// the results of the lookup.
	Finish(*module.Module, *license.License, error)

	// Close is called when all modules lookups are completed. This can be
	// used to output a summary report, if any.
	Close() error
}

Output represents the output format for the progress and completion of license lookups. This can be implemented to introduce new UI styles or output formats (like JSON, etc.).

type TermOutput

type TermOutput struct {
	// Out is the stdout to write to. If this is a TTY, TermOutput will
	// automatically use a "live" updating output mode for status updates.
	// This can be disabled by setting Plain to true below.
	Out io.Writer

	// Config is the configuration (if any). This will be used to check
	// if a license is allowed or not.
	Config *config.Config

	// Modules is the full list of modules that will be checked. This is
	// optional. If this is given in advance, then the output will be cleanly
	// aligned.
	Modules []module.Module

	// Plain, if true, will use the plain output vs the live updating output.
	// TermOutput will always use Plain output if the Out configured above
	// is not a TTY.
	Plain bool

	// Verbose will log all status updates in plain mode. This has no effect
	// in non-plain mode currently.
	Verbose bool
	// contains filtered or unexported fields
}

TermOutput is an Output implementation that outputs to the terminal.

func (*TermOutput) Close

func (o *TermOutput) Close() error

Close implements Output

func (*TermOutput) ExitCode

func (o *TermOutput) ExitCode() int

func (*TermOutput) Finish

func (o *TermOutput) Finish(m *module.Module, l *license.License, err error)

Finish implements Output

func (*TermOutput) Start

func (o *TermOutput) Start(m *module.Module)

Start implements Output

func (*TermOutput) Update

func (o *TermOutput) Update(m *module.Module, t license.StatusType, msg string)

Update implements Output

type XLSXOutput

type XLSXOutput struct {
	// Path is the path to the file to write. This will be overwritten if
	// it exists.
	Path string

	// Config is the configuration (if any). This will be used to check
	// if a license is allowed or not.
	Config *config.Config
	// contains filtered or unexported fields
}

XLSXOutput writes the results of license lookups to an XLSX file.

func (*XLSXOutput) Close

func (o *XLSXOutput) Close() error

Close implements Output

func (*XLSXOutput) Finish

func (o *XLSXOutput) Finish(m *module.Module, l *license.License, err error)

Finish implements Output

func (*XLSXOutput) Start

func (o *XLSXOutput) Start(m *module.Module)

Start implements Output

func (*XLSXOutput) Update

func (o *XLSXOutput) Update(m *module.Module, t license.StatusType, msg string)

Update implements Output

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL