cmd

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RepositoryFlag     = "@@REPOSITORY"
	TimezoneFlag       = "@@TIMEZONE"
	DatetimeFormatFlag = "@@DATETIME_FORMAT"
	WaitTimeoutFlag    = "@@WAIT_TIMEOUT"
	DelimiterFlag      = "@@DELIMITER"
	JsonQuery          = "@@JSON_QUERY"
	EncodingFlag       = "@@ENCODING"
	NoHeaderFlag       = "@@NO_HEADER"
	WithoutNullFlag    = "@@WITHOUT_NULL"
	FormatFlag         = "@@FORMAT"
	WriteEncodingFlag  = "@@WRITE_ENCODING"
	WriteDelimiterFlag = "@@WRITE_DELIMITER"
	WithoutHeaderFlag  = "@@WITHOUT_HEADER"
	LineBreakFlag      = "@@LINE_BREAK"
	PrettyPrintFlag    = "@@PRETTY_PRINT"
	ColorFlag          = "@@COLOR"
	QuietFlag          = "@@QUIET"
	CPUFlag            = "@@CPU"
	StatsFlag          = "@@STATS"
)
View Source
const (
	CsvExt   = ".csv"
	TsvExt   = ".tsv"
	FixedExt = ".txt"
	JsonExt  = ".json"
	GfmExt   = ".md"
	OrgExt   = ".org"
)
View Source
const (
	TerminalPrompt           string = "csvq > "
	TerminalContinuousPrompt string = "     > "
)
View Source
const HistoryFile = ".csvq_history"

Variables

Functions

func CreateFile added in v0.1.6

func CreateFile(filename string, s string) error

func EscapeString added in v0.8.0

func EscapeString(s string) string

func GetLocation

func GetLocation() *time.Location

func GetRand

func GetRand() *rand.Rand

func GetReader

func GetReader(r io.Reader, enc Encoding) io.Reader

func HumarizeNumber added in v0.6.1

func HumarizeNumber(s string) string

func IsReadableFromPipeOrRedirection added in v0.8.0

func IsReadableFromPipeOrRedirection() bool

func Now

func Now() time.Time

func ParseDelimiter added in v1.5.0

func ParseDelimiter(s string, delimiter rune, delimiterPositions []int, delimitAutomatically bool) (rune, []int, bool, error)

func SetCPU added in v0.6.2

func SetCPU(i int)

func SetColor added in v1.3.0

func SetColor(b bool)

func SetDatetimeFormat added in v0.2.7

func SetDatetimeFormat(s string)

func SetDelimiter

func SetDelimiter(s string) error

func SetEncoding

func SetEncoding(s string) error

func SetFormat

func SetFormat(s string) error

func SetJsonQuery added in v1.3.0

func SetJsonQuery(s string)

func SetLineBreak

func SetLineBreak(s string) error

func SetLocation added in v0.3.2

func SetLocation(s string) error

func SetNoHeader

func SetNoHeader(b bool)

func SetOut

func SetOut(s string) error

func SetPrettyPrint added in v1.3.0

func SetPrettyPrint(b bool)

func SetQuiet added in v0.7.7

func SetQuiet(b bool)

func SetRepository

func SetRepository(s string) error

func SetSource added in v0.1.6

func SetSource(s string) error

func SetStats added in v0.6.1

func SetStats(b bool)

func SetWaitTimeout added in v0.7.10

func SetWaitTimeout(f float64)

func SetWithoutHeader

func SetWithoutHeader(b bool)

func SetWithoutNull

func SetWithoutNull(b bool)

func SetWriteDelimiter

func SetWriteDelimiter(s string) error

func SetWriteEncoding

func SetWriteEncoding(s string) error

func ToStdout added in v0.1.6

func ToStdout(s string) error

func TryCreateFile added in v0.7.4

func TryCreateFile(filename string) error

func UnescapeString added in v0.1.5

func UnescapeString(s string) string

func UpdateFile added in v0.1.6

func UpdateFile(fp *os.File, s string) error

Types

type Encoding

type Encoding string
const (
	UTF8 Encoding = "UTF8"
	SJIS Encoding = "SJIS"
)

func ParseEncoding

func ParseEncoding(s string) (Encoding, error)

func (Encoding) String added in v0.1.6

func (e Encoding) String() string

type Flags

type Flags struct {
	// Common Settings
	Repository     string
	Location       string
	DatetimeFormat string
	WaitTimeout    float64

	// For Procedure
	Source string

	// For Import
	Delimiter   rune
	JsonQuery   string
	Encoding    Encoding
	NoHeader    bool
	WithoutNull bool

	// For Export
	OutFile        string
	Format         Format
	WriteEncoding  Encoding
	WriteDelimiter rune
	WithoutHeader  bool
	LineBreak      LineBreak
	PrettyPrint    bool

	// ANSI Color Sequence
	Color bool

	// System Use
	Quiet bool
	CPU   int
	Stats bool

	// Fixed Value
	RetryInterval time.Duration

	// For Fixed-Length Format
	DelimitAutomatically    bool
	DelimiterPositions      []int
	WriteDelimiterPositions []int

	// Use in tests
	Now string
}

func GetFlags

func GetFlags() *Flags

func (*Flags) ImportFormat added in v1.5.0

func (f *Flags) ImportFormat() Format

type Format

type Format int
const (
	AutoSelect Format = -1 + iota
	CSV
	TSV
	FIXED
	JSON
	JSONH
	JSONA
	GFM
	ORG
	TEXT
)

func ParseFormat added in v1.5.0

func ParseFormat(s string) (Format, error)

func (Format) String added in v1.1.0

func (f Format) String() string

type LineBreak

type LineBreak string
const (
	CR   LineBreak = "\r"
	LF   LineBreak = "\n"
	CRLF LineBreak = "\r\n"
)

func ParseLineBreak added in v1.5.0

func ParseLineBreak(s string) (LineBreak, error)

func (LineBreak) String added in v0.8.0

func (lb LineBreak) String() string

func (LineBreak) Value

func (lb LineBreak) Value() string

type ReadLineTerminal added in v0.8.1

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

func (ReadLineTerminal) GetSize added in v1.5.0

func (t ReadLineTerminal) GetSize() (int, int, error)

func (ReadLineTerminal) ReadLine added in v0.8.1

func (t ReadLineTerminal) ReadLine() (string, error)

func (ReadLineTerminal) SaveHistory added in v0.8.1

func (t ReadLineTerminal) SaveHistory(s string)

func (ReadLineTerminal) SetContinuousPrompt added in v0.8.1

func (t ReadLineTerminal) SetContinuousPrompt()

func (ReadLineTerminal) SetPrompt added in v0.8.1

func (t ReadLineTerminal) SetPrompt()

func (ReadLineTerminal) Teardown added in v0.8.1

func (t ReadLineTerminal) Teardown()

func (ReadLineTerminal) Write added in v0.8.1

func (t ReadLineTerminal) Write(s string) error

type VirtualTerminal added in v0.8.1

type VirtualTerminal interface {
	ReadLine() (string, error)
	Write(string) error
	SetPrompt()
	SetContinuousPrompt()
	SaveHistory(string)
	Teardown()
	GetSize() (int, int, error)
}
var Terminal VirtualTerminal

func NewTerminal added in v0.8.0

func NewTerminal() (VirtualTerminal, error)

Jump to

Keyboard shortcuts

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