resultset

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRINT_RUNE printItem = iota
	PRINT_RUNE_ISOLATED
	PRINT_RUNE_PRESENT_TEXT
	PRINT_RUNE_PRESENT_EMOJI
	PRINT_RUNE_PRESENT_LEFT
	PRINT_RUNE_PRESENT_RIGHT
	PRINT_RUNE__RENDERERS // items before this render the rune itself
	PRINT_RUNE_DEC
	PRINT_RUNE_HEX     // raw hex
	PRINT_RUNE_JSON    // surrogate pair in JSON syntax
	PRINT_RUNE_UTF8ENC // URL format
	PRINT_RUNE_PUNY
	PRINT_RUNE_WIDTH // best guess, terminal display cell width
	PRINT_NAME
	PRINT_BLOCK
	PRINT_HTML_ENTITIES
	PRINT_XML_ENTITIES
	PRINT_PART_OF // when we decomposed from input
)

These constants dictate what attribute of a rune should be printed.

View Source
const (
	FIELD_SET_DEFAULT fieldSetSelector = iota
	FIELD_SET_NET
	FIELD_SET_DEBUG
)

These constants determine which columns will appear in a table.

Variables

View Source
var ResultCmdFlags struct {
	JSON       bool
	Oneline    bool
	NetVerbose bool
	Verbose    bool
	Emoji      bool
	Text       bool
	Left       bool
	Right      bool
	// contains filtered or unexported fields
}

Functions

func CanTable added in v0.0.2

func CanTable() bool

CanTable is the interface for the caller to determine if we have table-support loaded at all. It mostly just avoids propagating imports of the table shim into every place which is already creating results.

func CmdVerbose added in v0.6.1

func CmdVerbose() bool

CmdVerbose indicates if a documented verbose flag was set; occasionally commands want to know for reasons other than a resultset (eg, 'character browse -vB').

func FlagsOkay added in v0.6.1

func FlagsOkay() error

FlagsOkay returns either ErrIncompatibleFlags or nil

func JItemWidth added in v0.6.1

func JItemWidth(x interface{}) int

JItemWidth converts to a width, for JSON

func RegisterCmdFlags added in v0.6.1

func RegisterCmdFlags(cmd *cobra.Command, supportOneline bool)

RegisterCmdFlags adds the --verbose/--net-verbose/--internal-debug flags to a Cobra cmd.

func S added in v0.6.1

func S(x interface{}) string

S converts to a string, for JSON

Types

type ErrIncompatibleFlags added in v0.6.1

type ErrIncompatibleFlags []string

ErrIncompatibleFlags indicates that multiple types of verboseness were simultaneously requested.

func (ErrIncompatibleFlags) Error added in v0.6.1

func (e ErrIncompatibleFlags) Error() string

type JCombination added in v0.6.2

type JCombination struct {
	Display string `json:"display"`
	Derived bool   `json:"derived"`
}

JCombination is something which might be shown instead of JItem

type JInfo added in v0.6.1

type JInfo struct {
	Comment string `json:"comment"`
}

JInfo is something which might be shown instead of JItem.

type JItem added in v0.6.1

type JItem struct {
	Display      string   `json:"display"`
	DisplayText  string   `json:"displayText"`
	DisplayEmoji string   `json:"displayEmoji"`
	DisplayLeft  string   `json:"displayLeft"`
	DisplayRight string   `json:"displayRight"`
	Name         string   `json:"name"`
	Hex          string   `json:"hex"`
	Dec          string   `json:"decimal"`
	Block        string   `json:"block"`
	VIMDigraphs  []string `json:"vimDigraphs,omitempty"`
	X11Digraphs  []string `json:"x11Digraphs,omitempty"`
	HTMLEntities []string `json:"htmlEntities,omitempty"`
	XMLEntities  []string `json:"xmlEntities,omitempty"`
	UTF8         string   `json:"utf8"`
	JSONEscape   string   `json:"jsonEscape"`
	RenderWidth  int      `json:"renderWidth"`
	Puny         string   `json:"puny"`
	PartOf       string   `json:"part-of,omitempty"`
}

JItem is how a character is represented in JSON output.

type ResultSet added in v0.6.1

type ResultSet struct {
	OutputStream io.Writer
	ErrorStream  io.Writer
	// contains filtered or unexported fields
}

A ResultSet is the collection of unicode characters (or near facsimiles thereof) about which we wish to see data. Various front-end commands just figure out which characters are being asked about and throw them in the ResultSet, then at the end the ResultSet is asked to print itself in an appropriate format, which might be in a table, as lines, or in other ways. For convenience, errors are also accumulated here. If emitting tables, the errors will be in a separate second table, but otherwise they're interleaved with the real characters in the correct order (but to stderr (probably), so if the streams diverge then this might not be reconstructible).

func New

func New(s *sources.Sources, sizeHint int) *ResultSet

New creates a ResultSet. We now make ResultSet an exported type, ugh, so this stutters when used. Most usage should never do that.

func (*ResultSet) AddCharInfo added in v0.6.1

func (rs *ResultSet) AddCharInfo(ci unicode.CharInfo)

AddCharInfo is used for recording character information as an item in the result set.

func (*ResultSet) AddCharInfoDerivedFrom added in v0.6.1

func (rs *ResultSet) AddCharInfoDerivedFrom(ci unicode.CharInfo, from rune)

AddCharInfoDerivedFrom is used when the character was decomposed by us, so that we can display original input if requested.

func (*ResultSet) AddDivider added in v0.6.1

func (rs *ResultSet) AddDivider()

AddDivider is use between words.

func (*ResultSet) AddError added in v0.6.1

func (rs *ResultSet) AddError(input string, e error)

AddError records, in-sequence, that we got an error at this point.

func (*ResultSet) AddStringSequence added in v0.6.2

func (rs *ResultSet) AddStringSequence(s string)

AddStringSequence is used where we have some combining sequence to be rendered as one

func (*ResultSet) ErrorCount added in v0.6.1

func (rs *ResultSet) ErrorCount() int

ErrorCount sums the number of errors in the entire ResultSet.

func (*ResultSet) JSONEntry added in v0.6.1

func (rs *ResultSet) JSONEntry(ci charItem) interface{}

JSONEntry constructs a probably-JItem struct for JSON rendering of a character.

func (*ResultSet) LenItemCount added in v0.6.1

func (rs *ResultSet) LenItemCount() int

LenItemCount yields how many successful items are in the table

func (*ResultSet) LenTotalCount added in v0.6.1

func (rs *ResultSet) LenTotalCount() int

LenTotalCount yields how many rows are in the resultset, including dividers and errors

func (*ResultSet) PrintJSON added in v0.6.1

func (rs *ResultSet) PrintJSON()

PrintJSON shows everything we know about each result, in JSON. Rather than array of char/div/error, we have two top-level arrays of results and a divider is represented by a nil item. Not sure how friendly that is for arbitrary input, but it helps with syncing I think (but errors inline might help more).

Note that this is distinct from using a JSON table renderer for the normal tables and is instead emitting completely different output.

func (*ResultSet) PrintPlain added in v0.6.1

func (rs *ResultSet) PrintPlain(what printItem)

PrintPlain shows just characters, but with full errors interleaved too. One character or error per line.

func (*ResultSet) PrintTables added in v0.6.1

func (rs *ResultSet) PrintTables()

PrintTables provides much more verbose details about the contents of a ResultSet, in a structured terminal table.

func (*ResultSet) RenderCharInfoItem added in v0.6.1

func (rs *ResultSet) RenderCharInfoItem(ci charItem, what printItem) interface{}

RenderCharInfoItem converts a charItem and an attribute selector into a string or Stringer

func (*ResultSet) RenderPerCmdline added in v0.6.1

func (rs *ResultSet) RenderPerCmdline(defaultPI printItem)

RenderPerCmdline performs the table rendering requested from the command-line, or iteration in non-table form, printing the item passed. This is otherwise per-command boilerplate.

func (*ResultSet) RunePrintType added in v0.6.1

func (rs *ResultSet) RunePrintType() printItem

RunePrintType returns PRINT_RUNE or one of its variants, appropriate to handle command-line-chosen variant selectors accordingly.

func (*ResultSet) SelectFieldsDebug added in v0.6.1

func (rs *ResultSet) SelectFieldsDebug()

SelectFieldsDebug says to show some internal diagnostics, not the default fields. This API call is very much subject to change.

func (*ResultSet) SelectFieldsNet added in v0.6.1

func (rs *ResultSet) SelectFieldsNet()

SelectFieldsNet says to use the network fields, not the default fields. This API call is very much subject to change.

func (*ResultSet) StringPlain added in v0.6.1

func (rs *ResultSet) StringPlain(what printItem) string

StringPlain returns the characters as chars in a word, dividers as a space.

Jump to

Keyboard shortcuts

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