Documentation ¶
Index ¶
- Constants
- Variables
- func CanTable() bool
- func CmdVerbose() bool
- func FlagsOkay() error
- func JItemWidth(x interface{}) int
- func RegisterCmdFlags(cmd *cobra.Command, supportOneline bool)
- func S(x interface{}) string
- type ErrIncompatibleFlags
- type JCombination
- type JInfo
- type JItem
- type ResultSet
- func (rs *ResultSet) AddCharInfo(ci unicode.CharInfo)
- func (rs *ResultSet) AddCharInfoDerivedFrom(ci unicode.CharInfo, from rune)
- func (rs *ResultSet) AddDivider()
- func (rs *ResultSet) AddError(input string, e error)
- func (rs *ResultSet) AddStringSequence(s string)
- func (rs *ResultSet) ErrorCount() int
- func (rs *ResultSet) JSONEntry(ci charItem) interface{}
- func (rs *ResultSet) LenItemCount() int
- func (rs *ResultSet) LenTotalCount() int
- func (rs *ResultSet) PrintJSON()
- func (rs *ResultSet) PrintPlain(what printItem)
- func (rs *ResultSet) PrintTables()
- func (rs *ResultSet) RenderCharInfoItem(ci charItem, what printItem) interface{}
- func (rs *ResultSet) RenderPerCmdline(defaultPI printItem)
- func (rs *ResultSet) RunePrintType() printItem
- func (rs *ResultSet) SelectFieldsDebug()
- func (rs *ResultSet) SelectFieldsNet()
- func (rs *ResultSet) StringPlain(what printItem) string
Constants ¶
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.
const ( FIELD_SET_DEFAULT fieldSetSelector = iota FIELD_SET_NET FIELD_SET_DEBUG )
These constants determine which columns will appear in a table.
Variables ¶
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
RegisterCmdFlags adds the --verbose/--net-verbose/--internal-debug flags to a Cobra cmd.
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
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 ¶
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
AddCharInfo is used for recording character information as an item in the result set.
func (*ResultSet) AddCharInfoDerivedFrom ¶ added in v0.6.1
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
AddError records, in-sequence, that we got an error at this point.
func (*ResultSet) AddStringSequence ¶ added in v0.6.2
AddStringSequence is used where we have some combining sequence to be rendered as one
func (*ResultSet) ErrorCount ¶ added in v0.6.1
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
LenItemCount yields how many successful items are in the table
func (*ResultSet) LenTotalCount ¶ added in v0.6.1
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
StringPlain returns the characters as chars in a word, dividers as a space.