Documentation ¶
Index ¶
- Constants
- func ExitOnError(e error, writer io.Writer, exitCode uint8, message string, ...)
- func HandleSignals()
- func PrintError(e error, writer io.Writer, message string, extra ...interface{}) bool
- func PrintErrorWithError(e error, writer io.Writer, message string, extra ...interface{}) bool
- type Flags
- type Input
- type Message
- type Output
- func (output *Output) Append(format string, values ...interface{})
- func (output *Output) Done()
- func (output *Output) Initialise(out, e io.Writer)
- func (output *Output) LinesManual() bool
- func (output *Output) NewSubBuffer(name string, key int) OutputInterface
- func (output *Output) OrderBySubBufferKeys() bool
- func (output *Output) OrderBySubBufferNames() bool
- func (output *Output) PrintSubBufferNames() bool
- func (output *Output) Reset()
- func (output *Output) SetSortKey(to int)
- func (output *Output) SetSortTransformator(to func(string) string)
- func (output *Output) SortKey() int
- func (output *Output) SortReversed() bool
- func (output *Output) ToggleLinesManual()
- func (output *Output) ToggleOrderBySubBufferKeys()
- func (output *Output) ToggleOrderBySubBufferNames()
- func (output *Output) TogglePrintSubBufferNames()
- func (output *Output) ToggleSortReversed()
- func (output *Output) Wait()
- func (output *Output) Write(values []byte) (int, error)
- func (output *Output) WriteE(e error) bool
- func (output *Output) WriteEMessage(e error, format string, values ...interface{}) bool
- func (output *Output) WriteError(format string, values ...interface{})
- func (output *Output) WriteFormatted(format string, values ...interface{})
- func (output *Output) WriteLine(values ...interface{})
- func (output *Output) WritePerLine(values ...interface{})
- func (output *Output) WriteSorted(format, sortkey string, values ...interface{})
- type OutputInterface
- type SortedOutput
- func (output *SortedOutput) Append(format string, values ...interface{})
- func (output *SortedOutput) Done()
- func (output *SortedOutput) Initialise(out, e io.Writer)
- func (output *SortedOutput) NewSubBuffer(name string, key int) OutputInterface
- func (output *SortedOutput) SetSortKey(to int)
- func (output *SortedOutput) SetSortTransformator(to func(string) string)
- func (output *SortedOutput) SortKey() int
- func (output *SortedOutput) WriteFormatted(format string, values ...interface{})
- func (output *SortedOutput) WriteSorted(format, sortkey string, values ...interface{})
- type TerminalInfo
Constants ¶
View Source
const ( // to debug or not to debug, that is the question DEBUG = false // this token stands for stdin STDIN_TOKEN = "-" // part file extension EXTENSION_PART = ".part" // global setting for FADVICE_DONTNEED before reading SET_FILE_ADVICE_DONTNEED = true // TODO add more colors and colours TERMINAL_COLOR_JUNK = "\x1b[" TERMINAL_COLOR_JUNK_LENGTH = "\x1b[xxxxx" TERMINAL_COLOR_CYAN = "\x1b[36;1m" TERMINAL_COLOR_BLUE = "\x1b[34;1m" TERMINAL_COLOR_GREEN = "\x1b[32;1m" TERMINAL_COLOR_RESET = "\x1b[0m" // FIXME unknown escape sequence: e TERMINAL_BACKGROUND_GREEN = "\\e[42mGreen" )
View Source
const ( // Aus dem Hintergrund müsste Rahn schießen, Rahn schießt - TOR, TOR, TOR, TOR! SUCCESS = 0 // for historic reasons, say 1 is FAILED FAILED = 1 // from a given list, at least one part failed. check stderr. PARTLY = 2 // output is empty, so a new line was not printed. EMPTY_OUTPUT = 9 // some of the output wasn't outputted because it was empty. PARTLY_EMPTY = 10 // maximum success. used internally for if exitCode > SUCCESSFUL SUCCESSFUL = 10 // this shouldn't happen. declare the program received an error, but doesn't // know how to handle it or even what it is. ERROR_UNSPECIFIED = 100 // it finally happend ERROR_DISK_FULL = 101 // access denied in resource ERROR_ACCESS_DENIED = 102 // couldn't write to resource ERROR_WRITE_ACCESS_DENID = 103 // no input given ERROR_NO_INPUT = 104 // unknown (kill) signal ERROR_INVALID_SIGNAL = 105 // error parsing input ERROR_PARSING = 106 // invalid argument ERROR_INVALID_ARGUMENT = 107 // couldn't get working directory ERROR_WORKING_DIRECTORY = 108 // doesn't exist ERROR_FILE_NOT_FOUND = 109 // file already exist. file will not be overriden ERROR_FILE_EXIST = 110 // open error ERROR_OPENING_FILE = 111 // reading error on io.Read ERROR_READING = 112 // couldn't stat inode ERROR_STAT = 113 // TODO remove ERROR_COMPAT = 199 // an unknown or unhandled internal error occured. ERROR_INTERNAL = 200 // access denied to internally used resource. config file for example. ERROR_INTERNAL_ACCESS_DENIED = 201 // write access denied to internally used resource. config file for example. ERROR_INTERNAL_WRITE_ACCESS_DENIED = 202 // unhandled error. naughty programmer! ERROR_UNHANDLED = 254 // this error should'nt be used. please be more fine grained. ERROR_GENERIC = 255 )
View Source
const ( // try not to open more then this amount of goroutines for one task GOROUTINE_LIMIT = 500 // perform a runtime.GC() followed by runtime.Gosched() when hitting GOROUTINE_LIMIT GOROUTINE_LIMIT_GC = true // try not to open more then this amount of goroutines for resources (files!) // must be divideable by 5 without leftovers GOROUTINE_LIMIT_RESOURCE = 50 // 1 of 5 GOROUTINE_LIMIT_RESOURCE_1OF5 = GOROUTINE_LIMIT_RESOURCE / 5 // 4 of 5 GOROUTINE_LIMIT_RESOURCE_4OF5 = GOROUTINE_LIMIT_RESOURCE_1OF5 * 4 // the smallest read for an io.Reader buffer READ_BUFFER_SMALL_SIZE = 512 // the usual read size for an io.Reader buffer READ_BUFFER_SIZE = 4 * 1024 // the maximum read size for an io.Reader buffer READ_BUFFER_MAXIMUM_SIZE = 32 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func ExitOnError ¶
if e != nil, exit
func HandleSignals ¶
func HandleSignals()
func PrintError ¶
Types ¶
type Flags ¶
type Flags struct {
HasVerbose, HasHelp, HasVersion bool
// tells you the level of verbosiness the user wants
FlagVerboseLevel uint
Debug bool
// contains filtered or unexported fields
}
func (*Flags) AddGeneralOptions ¶
func (flags *Flags) AddGeneralOptions()
func (*Flags) ParseOption ¶
type Input ¶
type Output ¶
write in a separate goroutine to output writers (stdout, stderr)
func (*Output) Initialise ¶
func (*Output) LinesManual ¶
func (*Output) NewSubBuffer ¶
func (output *Output) NewSubBuffer(name string, key int) OutputInterface
TODO add a possibilty to asynchronously flushing the buffer to it's parent when done TODO add a copy function return a new subbuffer that is automatically flushed to the main buffer when done name can be printed, key can be used for keeping a sort order in output
func (*Output) OrderBySubBufferKeys ¶
func (*Output) OrderBySubBufferNames ¶
func (*Output) PrintSubBufferNames ¶
func (*Output) SetSortKey ¶
func (*Output) SetSortTransformator ¶
func (*Output) SortReversed ¶
func (*Output) ToggleLinesManual ¶
func (output *Output) ToggleLinesManual()
func (*Output) ToggleOrderBySubBufferKeys ¶
func (output *Output) ToggleOrderBySubBufferKeys()
func (*Output) ToggleOrderBySubBufferNames ¶
func (output *Output) ToggleOrderBySubBufferNames()
func (*Output) TogglePrintSubBufferNames ¶
func (output *Output) TogglePrintSubBufferNames()
func (*Output) ToggleSortReversed ¶
func (output *Output) ToggleSortReversed()
func (*Output) WriteEMessage ¶
func (*Output) WriteError ¶
func (*Output) WriteFormatted ¶
func (*Output) WritePerLine ¶
func (output *Output) WritePerLine(values ...interface{})
func (*Output) WriteSorted ¶
write unsorted
type OutputInterface ¶
type OutputInterface interface { sync.Locker io.Writer Initialise(io, e io.Writer) WriteFormatted(format string, values ...interface{}) WriteLine(values ...interface{}) WritePerLine(values ...interface{}) // buffer output if aplicable and sort it before outputting WriteSorted(format, sortkey string, values ...interface{}) // used for sorted output, otherwise the same as Write Append(format string, values ...interface{}) WriteE(e error) bool WriteEMessage(e error, format string, values ...interface{}) bool WriteError(format string, values ...interface{}) // state you are done. close channels Done() // wait till everyting is written Wait() SortKey() int SetSortKey(to int) SetSortTransformator(to func(string) string) SortReversed() bool ToggleSortReversed() LinesManual() bool ToggleLinesManual() NewSubBuffer(name string, key int) OutputInterface PrintSubBufferNames() bool TogglePrintSubBufferNames() OrderBySubBufferNames() bool ToggleOrderBySubBufferNames() OrderBySubBufferKeys() bool ToggleOrderBySubBufferKeys() // contains filtered or unexported methods }
func NewOutput ¶
func NewOutput(out, e io.Writer) (output OutputInterface)
func NewSortedOutput ¶
func NewSortedOutput(out, e io.Writer) (output OutputInterface)
func NewSortedTabbedOutput ¶
func NewSortedTabbedOutput(out, e io.Writer) OutputInterface
func NewTabbedOutput ¶
func NewTabbedOutput(out, e io.Writer) OutputInterface
type SortedOutput ¶
type SortedOutput struct { Output // contains filtered or unexported fields }
buffers the output, but not e, until Done(), sorts that and outputs it to the given output
func (*SortedOutput) Append ¶
func (output *SortedOutput) Append(format string, values ...interface{})
append to the last sort key
func (*SortedOutput) Done ¶
func (output *SortedOutput) Done()
func (*SortedOutput) Initialise ¶
func (output *SortedOutput) Initialise(out, e io.Writer)
func (*SortedOutput) NewSubBuffer ¶
func (output *SortedOutput) NewSubBuffer(name string, key int) OutputInterface
TODO add a copy function
func (*SortedOutput) SetSortKey ¶
func (output *SortedOutput) SetSortKey(to int)
func (*SortedOutput) SetSortTransformator ¶
func (output *SortedOutput) SetSortTransformator(to func(string) string)
func (*SortedOutput) SortKey ¶
func (output *SortedOutput) SortKey() int
func (*SortedOutput) WriteFormatted ¶
func (output *SortedOutput) WriteFormatted(format string, values ...interface{})
soft sort. tries to use the first value as stringkey
func (*SortedOutput) WriteSorted ¶
func (output *SortedOutput) WriteSorted(format, sortkey string, values ...interface{})
type TerminalInfo ¶
type TerminalInfo struct {
// contains filtered or unexported fields
}
func NewTerminalInfo ¶
func NewTerminalInfo() *TerminalInfo
func (*TerminalInfo) Width ¶
func (terminal *TerminalInfo) Width() int
Click to show internal directories.
Click to hide internal directories.