thelm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UiAbortedErr = fmt.Errorf("User interface was aborted")

UiAbortedErr tells if user wanted to abort

View Source
var UiSelectedErr = fmt.Errorf("User selected a line")

UiSelectedErr tells that user selected a line

Functions

func AsRelaxedRegexp

func AsRelaxedRegexp(regex string) (ret string)

AsRelaxedRegexp converts spaces in a string to .*

func CheckSelfRunning

func CheckSelfRunning(opts appkit.Options) (err error)

func Cli

func Cli(opts appkit.Options, argsin []string) (args []string, err error)

func DefaultConfigFile

func DefaultConfigFile(opts appkit.Options) string

DefaultConfigFile gets the default configuration file name based on given Options

func ErrAnnotate added in v0.6.0

func ErrAnnotate(err error, a ...interface{}) error

func Ui

func Ui(opts appkit.Options, args []string) (ret string, err error)

Ui runs the user interface that selects the line from input

Types

type AsyncSource

type AsyncSource interface {
	Run(...string) error
	Wait()
	Finish() error

	IsOneShot() bool

	// Set callback that provides data out
	SetOutput(io.Writer)
}

type Buffer

type Buffer struct {

	// Callback that provides data out
	Passthrough io.Writer
	// contains filtered or unexported fields
}

func (*Buffer) Close

func (b *Buffer) Close() error

Close makes sure the asynchronous filtering is really stopped

func (*Buffer) Filter

func (b *Buffer) Filter(regex string) (err error)

Filter the current Buffer with the regexp and write output to out.

func (*Buffer) GetRealLine

func (b *Buffer) GetRealLine(line int) (realLine int)

GetRealLine gets the original buffer line for the given line in the filtered output

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

Read satisfies io.Reader. Reads data from the buffer.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write satisfies io.Writer. Writes data into the buffer.

type Command

type Command struct {
	MaxLines int

	Source
	// contains filtered or unexported fields
}

func (*Command) Finish

func (c *Command) Finish() (err error)

Finish makes sure the process has stopped

func (*Command) IsOneShot

func (c *Command) IsOneShot() bool

func (*Command) Run

func (c *Command) Run(args ...string) (err error)

Run given command with args

func (*Command) Wait

func (c *Command) Wait()

Wait waits for the command to complete

func (*Command) Write

func (c *Command) Write(p []byte) (n int, err error)

Data will be written to the internal buffer from another process

type Profiler

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

Profiler is a structure to simplify generating CPU and memory profile files from a run of a program.

func SetupProfiler added in v0.6.0

func SetupProfiler(opts appkit.Options) (*Profiler, error)

SetupProfiler sets up an empty profiler with Options. The options should contain keys "profile-cpu-file" which is the file name for the CPU profile. Also the memory profile will be written to value of key "profile-mem-file".

func (*Profiler) Close

func (p *Profiler) Close() error

Close finishes the creation of the profile. Should be defer'd after running Setup.

type Source

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

func (*Source) SetOutput

func (s *Source) SetOutput(p io.Writer)

type SourceFile

type SourceFile struct {
	FileName string

	SourceReader
}

func (*SourceFile) Run

func (f *SourceFile) Run(args ...string) (err error)

func (*SourceFile) Wait

func (f *SourceFile) Wait()

type SourceReader

type SourceReader struct {
	Input io.Reader

	Source
	// contains filtered or unexported fields
}

func (*SourceReader) Finish

func (r *SourceReader) Finish() (err error)

func (*SourceReader) IsOneShot

func (r *SourceReader) IsOneShot() bool

func (*SourceReader) Run

func (r *SourceReader) Run(...string) error

func (*SourceReader) Wait

func (r *SourceReader) Wait()

type UIView

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

UIView is the graphical representation of the data. It is used to draw the data to the screen.

func (*UIView) Clear

func (u *UIView) Clear()

Clear clears the view buffer

func (*UIView) Flush

func (u *UIView) Flush()

Flush updates the whole screen

func (*UIView) GetDataLineCount

func (u *UIView) GetDataLineCount() (ret int)

GetDataLineCount returns the number of lines in the view

func (*UIView) GetHighlightLine

func (u *UIView) GetHighlightLine() (string, int)

GetHighlightLine returns the string and the line from the view buffer that is currently highlighted

func (*UIView) MoveHighlightAndView

func (u *UIView) MoveHighlightAndView(ydiff int)

MoveHighlightAndView moves the highlight primarily. Can shift the view if at limits.

func (*UIView) Read

func (u *UIView) Read(p []byte) (n int, err error)

Read reads the view data contents. This too can be called from anywhere.

func (*UIView) SetInputLine

func (u *UIView) SetInputLine(line string, cursorx int)

SetInputLine sets the input line to given and moves the cursor to absolute x

func (*UIView) SetStatusLine

func (u *UIView) SetStatusLine(line string)

SetStatusLine sets the status line to a given string

func (*UIView) ViewSize

func (u *UIView) ViewSize() (x int, y int)

ViewSize returns the size of the view

func (*UIView) Write

func (u *UIView) Write(p []byte) (n int, err error)

Write writes the given data to the view. This can be called from anywhere.

Jump to

Keyboard shortcuts

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