Print status lines debian init-style.
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