line

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Base text effects.
	Reset      = "\x1b[0m"
	Bold       = "\x1b[1m"
	Dim        = "\x1b[2m"
	Underscore = "\x1b[4m"
	Blink      = "\x1b[5m"
	Reverse    = "\x1b[7m"

	// Effects reset.
	BoldReset       = "\x1b[22m" // 21 actually causes underline instead
	DimReset        = "\x1b[22m"
	UnderscoreReset = "\x1b[24m"
	BlinkReset      = "\x1b[25m"
	ReverseReset    = "\x1b[27m"

	// Colors
	GreenFG       = "\x1b[32m"
	YellowFG      = "\x1b[33m"
	ResetFG       = "\x1b[39m"
	BrightWhiteFG = "\x1b[38;05;244m"
)
View Source
var (
	SplitChars        = " \n\t"
	SingleChar        = '\''
	DoubleChar        = '"'
	EscapeChar        = '\\'
	DoubleEscapeChars = "$`\"\n\\"
)
View Source
var (
	ErrUnterminatedSingleQuote = errors.New("unterminated single-quoted string")
	ErrUnterminatedDoubleQuote = errors.New("unterminated double-quoted string")
	ErrUnterminatedEscape      = errors.New("unterminated backslash-escape")
)

Functions

func AcceptMultiline

func AcceptMultiline(line []rune) (accept bool)

acceptMultiline determines if the line just accepted is complete (in which case we should execute it), or incomplete (in which case we must read in multiline).

func HighlightCommand

func HighlightCommand(done, args []string, root *cobra.Command, cmdColor string) ([]string, []string)

HighlightCommand applies highlighting to commands in an input line.

func HighlightCommandFlags

func HighlightCommandFlags(done, args []string, flagColor string) ([]string, []string)

HighlightCommand applies highlighting to command flags in an input line.

func IsEmpty

func IsEmpty(line string, emptyChars ...rune) bool

IsEmpty checks if a given input line is empty. It accepts a list of characters that we consider to be irrelevant, that is, if the given line only contains these characters, it will be considered empty.

func Parse

func Parse(line string) (args []string, err error)

Parse is in charge of removing all comments from the input line before execution, and if successfully parsed, split into words.

func Split

func Split(input string, hl bool) (words []string, remainder string, err error)

Split has been copied from go-shellquote and slightly modified so as to also return the remainder when the parsing failed because of an unterminated quote.

func TrimSpaces

func TrimSpaces(remain []string) (trimmed []string)

TrimSpaces removes all leading/trailing spaces from words

func UnescapeValue

func UnescapeValue(prefixComp, prefixLine, val string) string

UnescapeValue is used When the completer has returned us some completions, we sometimes need to post-process them a little before passing them to our shell.

Types

This section is empty.

Jump to

Keyboard shortcuts

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