# README
status

Print status lines debian init-style.
Usage
In any package where status output should be printed to the command line, simply import "github.com/els0r/status"
and access the familiar functions with
status.Line("Updating database")
// do something awesomely magical
// ...
status.Okf("%d/10 entries updated", 10)
The two functions Custom
and AnyStatus
allow you to customize what is written
into the enclosed status. Say you want to print DONE instead of OK, then use Custom
:
status.Line("Waiting for database update")
status.Custom(status.Blue, "DONE", "10/10 entries updated")
By default Custom
truncates whatever you supply as the status argument to four characters such that the width is not altered with regard to the standard status types.
If you don't care and want it to be of arbitrary width, use AnyStatus
:
status.Line("Status of database")
status.AnyStatus(status.Green, "UPDATED", "10/10 entries updated")
If you want to control where the output is sent, you can explicitly set an io.Writer
object with SetOutput
. The default writer will be os.Stdout
. Example:
type myWriter struct{} // implements Write method of io.Writer
mw := myWriter{}
status.SetOutput(mw) // statusline output now handled by your own Write() implementation
# Functions
AnyStatus is the same as AnyStatusf with a fixed message string.
AnyStatusf is the same as Customf without the status length constraint.
Attn is an alias for Warn.
Attnf is an alias for Warnf.
Custom is Customf with with fixed message string.
Customf is a function allowing the user to set the status to something other than OK, ATTN, or FAIL.
Fail prints a FAIL event enclosed by brackets.
Failf prints a FAIL event enclosed by brackets with formatted status explanation.
Line prints msg on a new line.
Linef prints the status on a new line allowing for the status text to be formatted.
Ok prints an OK status event enclosed by brackets and appends msg as the status explanation.
Okf prints an OK status event enclosed by brackets with formatted status explanation.
SetOutput allows the user to control where the status should be written to.
Warn prints an ATTN status enclosed by brackets and appends msg as the status explanation.
Warnf prints an ATTN status enclosed by brackets with formatted status explanation.
# Constants
Supported colors (bold by default).
Supported colors (bold by default).
Supported colors (bold by default).
Supported colors (bold by default).
Supported colors (bold by default).
Supported colors (bold by default).
Supported colors (bold by default).
StatusLineIndent is exported in case people want to adapt other formatting to the status line width.
Supported colors (bold by default).
Supported colors (bold by default).
# Type aliases
Color provides access to colors used by the status printer.