diff

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{Context: 10, Color: true}

DefaultOptions are the default options that are used if none are provided.

Functions

This section is empty.

Types

type Differ

type Differ interface {
	// Print uses p to print a diff to w.
	Print(p Printer, w io.Writer) error
}

Differ is the interface for a Differ.

type Options

type Options struct {
	// Context is the number of unchanged lines before and after each changed
	// block that should also be printed to give some more context on the
	// change.
	Context int

	// Color enables colored diff output.
	Color bool
}

Options control the behaviour and output of the Differ.

type PathDiffer

type PathDiffer struct {
	From, To string
}

PathDiffer recursively diffs files in paths.

func NewPathDiffer

func NewPathDiffer(from, to string) *PathDiffer

NewPathDiffer creates a new PathDiffer for the two paths provided. If both paths are files, it will just produce a diff of them. If either of the two is a directory, the differ will recursively walk directories and diff all contained files.

func (*PathDiffer) Print

func (d *PathDiffer) Print(p Printer, w io.Writer) error

Print implements Differ. It writes diffs for all files in the from and to paths to w using p.

type Printer

type Printer interface {
	// Print prints a diff for subject s to w.
	Print(s Subject, w io.Writer) error
}

Printer is the interface for a diff printer.

type RemovalDiffer

type RemovalDiffer struct {
	Object runtime.Object
	Name   string
}

RemovalDiffer creates a diff for an object removal.

func NewRemovalDiffer

func NewRemovalDiffer(name string, obj runtime.Object) *RemovalDiffer

NewRemovalDiffer creates a new *RemovalDiffer for given obj. The name parameter is used to display a useful name identifying the object in the diff header.

func (*RemovalDiffer) Print

func (d *RemovalDiffer) Print(p Printer, w io.Writer) error

Print implements Differ. It writes an object removal diff to w using p.

type Subject

type Subject struct {
	A, B             string
	FromFile, ToFile string
}

Subject holds the contents and filenames to compare. FromFile and ToFile are just used in the diff header to provide some context on what is being diffed.

type UnifiedPrinter

type UnifiedPrinter struct {
	Options Options
}

UnifiedPrinter printes unified diffs.

func NewUnifiedPrinter

func NewUnifiedPrinter(o Options) UnifiedPrinter

NewPrinter creates a new unified diff printer with diff options.

func (UnifiedPrinter) Print

func (p UnifiedPrinter) Print(s Subject, w io.Writer) error

Print implements Printer.

Jump to

Keyboard shortcuts

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