Documentation ¶
Overview ¶
Package status is a go implementation of a debian-like statusline.
The idea of the package is that no prior configuration needs to be applied before using it so that functions can be called "off-the-shelf"
Example:
package main import ( "os" "time" "github.com/els0r/status" ) func main() { // print a status line status.Linef("Waiting %d seconds", 5) time.Sleep(5*time.Second) status.Ok("") // now write to stderr status.SetOutput(os.Stderr) // print another status line status.Linef("Alerting you in %d seconds", 5) time.Sleep(5*time.Second) status.Warn("this went to stderr") }
Index ¶
- Constants
- func AnyStatus(color Color, status, msg string)
- func AnyStatusf(color Color, status, fmtStr string, args ...interface{})
- func Attn(msg string)
- func Attnf(fmtStr string, args ...interface{})
- func Custom(color Color, status, msg string)
- func Customf(color Color, status, fmtStr string, args ...interface{})
- func Fail(msg string)
- func Failf(fmtStr string, args ...interface{})
- func Line(msg string)
- func Linef(fmtStr string, args ...interface{})
- func Ok(msg string)
- func Okf(fmtStr string, args ...interface{})
- func SetOutput(w io.Writer)
- func Warn(msg string)
- func Warnf(fmtStr string, args ...interface{})
- type Color
Constants ¶
const StatusLineIndent = 54
StatusLineIndent is exported in case people want to adapt other formatting to the status line width
Variables ¶
This section is empty.
Functions ¶
func AnyStatusf ¶
AnyStatusf is the same as Customf without the status length constraint
func Customf ¶
Customf is a function allowing the user to set the status to something other than OK, ATTN, or FAIL.
Arguments:
- color: any available color from the enumerated constants (e.g. Blue)
- status: the enclosed status. Will be trimmed to 4 characters to fit the
- fmtStr: the format string (message)
- args: arguments to the message
func Failf ¶
func Failf(fmtStr string, args ...interface{})
Failf prints a FAIL event enclosed by brackets with formatted status explanation
func Linef ¶
func Linef(fmtStr string, args ...interface{})
Linef prints the status on a new line allowing for the status text to be formatted
func Ok ¶
func Ok(msg string)
Ok prints an OK status event enclosed by brackets and appends msg as the status explanation
func Okf ¶
func Okf(fmtStr string, args ...interface{})
Okf prints an OK status event enclosed by brackets with formatted status explanation