vxsv

package module
v0.0.0-...-d7da9ff Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 16 Imported by: 0

README

vxsv

view x separated values.

A terminal viewer for tabular data (CSV, TSV, etc.) Can also be used as a pager for scrolling through Postgres / MySQL command line output.

asciicast

installation

go get -u github.com/erik/vxsv/cmd/vxsv

usage

$ vxsv --help

Usage:
  vxsv [--psql | --mysql | --delimiter=DELIM | --tabs]
       [--no-headers] [--count=N] [PATH | -]
  vxsv -h | --help

Arguments:
  PATH     file to load [defaults to stdin]

Options:
  -h --help                 show this help message and exit.
  -p --psql                 parse output of psql cli (used as a pager)
  -m --mysql                parse output of mysql cli
  -n --count=N              only read N records.
  -H --no-headers           don't read headers from first row (for separated values)
  -d --delimiter=DELIM      separator for values [default: ,].
  -t --tabs                 use tabs as separator value.
postgres
$ PAGER='vxsv -p' psql ...
mysql
$ mysql ...

mysql> \P vxsv -m

Documentation

Index

Constants

View Source
const (
	CmpEq = iota
	CmpNeq
	CmpGt
	CmpGte
	CmpLt
	CmpLte
	CmpMatch
	CmpNoMatch
)
View Source
const (
	ColumnDefault = iota
	ColumnCollapsed
	ColumnExpanded

	// TODO: Move this to the Modified attribute
	ColumnAligned
)
View Source
const CellSeparator = " │ "
View Source
const HelpText = `` /* 3094-byte string literal not displayed */
View Source
const HiliteBg = termbox.ColorWhite
View Source
const HiliteFg = termbox.ColorBlack | termbox.AttrBold
View Source
const MaxCellWidth = 20
View Source
const OpChars = "!=><~"
View Source
const RowIndicator = '»'

Variables

View Source
var CmpOpRegex = regexp.MustCompile(`^(.+?)([!=><~]+)(.+)$`)

Functions

This section is empty.

Types

type Column

type Column struct {
	Name string

	// Display options
	Display   ColumnDisplay
	Pinned    bool
	Highlight bool
	Width     int

	Modified        bool
	ModifiedValues  []string
	ModifiedCommand string
}

type ColumnDisplay

type ColumnDisplay int

type ColumnFilter

type ColumnFilter struct {
	// contains filtered or unexported fields
}

func (ColumnFilter) Matches

func (f ColumnFilter) Matches(row []string) bool

func (ColumnFilter) String

func (f ColumnFilter) String() string

type ComparisonType

type ComparisonType int

type EmptyFilter

type EmptyFilter struct{}

func (EmptyFilter) Matches

func (f EmptyFilter) Matches([]string) bool

func (EmptyFilter) String

func (f EmptyFilter) String() string

type Filter

type Filter interface {
	String() string
	Matches(row []string) bool
}

type HandlerColumnSelect

type HandlerColumnSelect struct {
	HandlerDefault
	// contains filtered or unexported fields
}

func NewColumnSelect

func NewColumnSelect(ui *UI) *HandlerColumnSelect

func (*HandlerColumnSelect) HandleKey

func (h *HandlerColumnSelect) HandleKey(ev termbox.Event)

func (*HandlerColumnSelect) Len

func (h *HandlerColumnSelect) Len() int

func (*HandlerColumnSelect) Less

func (h *HandlerColumnSelect) Less(i, j int) bool

func (*HandlerColumnSelect) Repaint

func (h *HandlerColumnSelect) Repaint()

func (*HandlerColumnSelect) Swap

func (h *HandlerColumnSelect) Swap(i, j int)

type HandlerDefault

type HandlerDefault struct {
	// contains filtered or unexported fields
}

func (*HandlerDefault) HandleKey

func (h *HandlerDefault) HandleKey(ev termbox.Event)

func (*HandlerDefault) Repaint

func (h *HandlerDefault) Repaint()

type HandlerFilter

type HandlerFilter struct {
	HandlerDefault
	// contains filtered or unexported fields
}

func (*HandlerFilter) HandleKey

func (h *HandlerFilter) HandleKey(ev termbox.Event)

func (*HandlerFilter) Repaint

func (h *HandlerFilter) Repaint()

type HandlerPopup

type HandlerPopup struct {
	HandlerDefault
	// contains filtered or unexported fields
}

func NewPopup

func NewPopup(ui *UI, content string) *HandlerPopup

func (*HandlerPopup) HandleKey

func (h *HandlerPopup) HandleKey(ev termbox.Event)

func (*HandlerPopup) Repaint

func (h *HandlerPopup) Repaint()

type HandlerRowSelect

type HandlerRowSelect struct {
	HandlerDefault
	// contains filtered or unexported fields
}

func (*HandlerRowSelect) HandleKey

func (h *HandlerRowSelect) HandleKey(ev termbox.Event)

func (*HandlerRowSelect) Repaint

func (h *HandlerRowSelect) Repaint()

type HandlerShell

type HandlerShell struct {
	HandlerDefault
	// contains filtered or unexported fields
}

func (*HandlerShell) HandleKey

func (h *HandlerShell) HandleKey(ev termbox.Event)

func (*HandlerShell) Repaint

func (h *HandlerShell) Repaint()

type ModeHandler

type ModeHandler interface {
	HandleKey(ev termbox.Event)
	Repaint()
}

type RowFilter

type RowFilter struct {
	// contains filtered or unexported fields
}

func (RowFilter) Matches

func (f RowFilter) Matches(row []string) bool

func (RowFilter) String

func (f RowFilter) String() string

type TabularData

type TabularData struct {
	Columns []Column
	Rows    [][]string
}

func ReadCSVFile

func ReadCSVFile(reader io.Reader, delimiter rune, readHeader bool, count int64) (*TabularData, error)

func ReadMySQLTable

func ReadMySQLTable(reader io.Reader, count int64) (*TabularData, error)

Parses MySQL output format:

+------+------+------+ | colA | colB | colC | +------+------+------+ | foo | bar | baz | | foo2 | bar2 | baz2 | +------+------+------+ 2 rows in set

func ReadPSQLTable

func ReadPSQLTable(reader io.Reader, count int64) (*TabularData, error)

Parses Postgres output format:

colA | colB | colC

------+------+-----

foo  | bar  | baz
foo2 | bar2 | baz2

(2 rows)

type UI

type UI struct {
	// contains filtered or unexported fields
}

func NewUI

func NewUI(data *TabularData) *UI

func (*UI) Init

func (ui *UI) Init() error

func (*UI) Loop

func (ui *UI) Loop()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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