cmdlib

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPwdsToReport

func AddPwdsToReport(report *[][]string)

AddPwdsToReport Add working directories to the report

func Cli

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

func DebugTrace

func DebugTrace(args ...interface{})

func EnvStringFlag

func EnvStringFlag(set *flag.FlagSet, name, defvalue, usage, envVar string) *string

func FileExists

func FileExists(filename string) bool

func FormatRelativeTime

func FormatRelativeTime(diff time.Duration) string

FormatRelativeTime converts a duration to a string according to magnitudes above

func FormatTime

func FormatTime(timeint int64, now time.Time) string

FormatTime formats the given timestring (UNIX time) to human readable string

func ParseCmdLog

func ParseCmdLog(reader LineReader, arg ParseArgs) (err error)

ParseCmdLog Parses and prints out the command log from given reader. Possibly filter by session.

func ParseCmdLogLineNoAlloc

func ParseCmdLogLineNoAlloc(line string, session string, since int64, now time.Time, regex *regexp.Regexp,
	out *[]string)

ParseCmdLogLineNoAlloc prepares a single line without unnecessary allocation.

Types

type BufferedReader

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

func NewBufferedReader

func NewBufferedReader(f io.Reader, maximumLineLength int) (ret *BufferedReader)

func (*BufferedReader) ReadLine

func (f *BufferedReader) ReadLine() (string, error)

type BufferedWriter

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

BufferedWriter flushes given data every "lines" number of Write calls.

func NewBufferedWriter

func NewBufferedWriter(o io.Writer, lines int) *BufferedWriter

func (*BufferedWriter) Close

func (b *BufferedWriter) Close() error

func (*BufferedWriter) Write

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

type LineReader

type LineReader interface {
	ReadLine() (string, error)
}

type Log

type Log struct {
	LogFile    string
	Filters    []string
	FilterFile string
}

func CreateLog

func CreateLog(logfile, filterfile string) *Log

func (*Log) AppendLine

func (l *Log) AppendLine(session string, args string) error

AppendLine creates a log line to the given logfile

func (*Log) LoadFilters

func (l *Log) LoadFilters() error

func (*Log) SaveDefaultFilters

func (l *Log) SaveDefaultFilters() error

SaveDefaultFilters saves the default filters as an example if such file does not yet exist.

type ParseArgs

type ParseArgs struct {
	Session string
	Since   string
	Grep    string
	Pwd     bool
	Control controlArgs
	Output  io.Writer
}

ParseArgs is extendable list of arguments for the parseCmdLog function

type ReverseReader

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

func NewReverseReader

func NewReverseReader(f io.ReadSeeker, maximumLineLength int) (ret *ReverseReader, err error)

func (*ReverseReader) ReadLine

func (r *ReverseReader) ReadLine() (line string, err error)

Jump to

Keyboard shortcuts

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