File: option.go

package info (click to toggle)
golang-github-pkg-diff 0.0~git20210226.20ebb0f-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,528 kB
  • sloc: makefile: 3
file content (39 lines) | stat: -rw-r--r-- 802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Package write provides routines for writing diffs.
package write

// An Option modifies behavior when writing a diff.
type Option interface {
	isOption()
}

// Names provides the before/after names for writing a diff.
// They are traditionally filenames.
func Names(a, b string) Option {
	return names{a, b}
}

type names struct {
	a, b string
}

func (names) isOption() {}

// TerminalColor specifies that a diff intended
// for a terminal should be written using colors.
//
// Do not use TerminalColor if TERM=dumb is set in the environment.
func TerminalColor() Option {
	return colorOpt(true)
}

type colorOpt bool

func (colorOpt) isOption() {}

const (
	ansiBold    = "\u001b[1m"
	ansiFgRed   = "\u001b[31m"
	ansiFgGreen = "\u001b[32m"
	ansiFgBlue  = "\u001b[36m"
	ansiReset   = "\u001b[0m"
)