tools

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "tools.star"
View Source
const Name = "tools"

Variables

View Source
var Module = &starlarkstruct.Module{
	Name: "tools",
	Members: starlark.StringDict{
		"diff": localctx.AddBuiltin("tools.diff", DiffOfStr),
	},
}

Functions

func DiffOfStr

func DiffOfStr(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func PPDiff

func PPDiff(left, right []string) string

PPDiff returns the results of diffing left and right as an pretty printed string. It will display all the lines of both the sequences that are being compared. When the left is different from right it will prepend a " - |" before the line. When the right is different from left it will prepend a " + |" before the line. When the right and left are equal it will prepend a " |" before the line.

Types

type DeltaType

type DeltaType int
const (
	Common DeltaType = iota
	LeftOnly
	RightOnly
)

func (DeltaType) String

func (t DeltaType) String() string

String returns a string representation for DeltaType.

type DiffRecord

type DiffRecord struct {
	Payload   string
	Delta     DeltaType
	LineLeft  int
	LineRight int
}

func Diff

func Diff(seq1, seq2 []string) (diff []DiffRecord)

Diff returns the result of diffing the seq1 and seq2.

func (DiffRecord) String

func (d DiffRecord) String() string

String returns a string representation of d. The string is a concatenation of the delta type and the payload.

Jump to

Keyboard shortcuts

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