 @warn = @w = createWriter WARN, styler.warn
 
 @error = @e = do ->
-    errorWriter = createWriter ERROR, styler.error, process.stderr
+    errorWriter = createWriter ERROR, styler.error, stderr
     (msg, end = yes, exitCode = 1) ->
         ret = errorWriter msg
-        process.exit exitCode if end is yes
+        exit exitCode if end is yes
         ret
 
 

_ = require 'lodash'
assert = require 'assert'
readline = require 'readline'

styler = require './styler'
{ verbose } = require './cli'

module.exports = @

# Constants
[INFO,WARN,ERROR,VERBOSE] = TAGS = ["INFO", "WARN", "ERROR", "VERBS"]
LEFT_MARGIN = _.maxBy(TAGS, _.size).length + 1
TAG_INDICATOR = ': '
LEFT_PADSTRING_LONG_LINES = _.repeat(" ", LEFT_MARGIN + TAG_INDICATOR.length)
MAX_COLS_PER_LINE = Math.max 10, process.stdout.columns - LEFT_PADSTRING_LONG_LINES.length - 1

# Private methods
tag = (txt, style) -> style(_.padEnd(txt, LEFT_MARGIN)) + TAG_INDICATOR

# Exposed methods
@endLine = => console.log(""); @

@eraseLine = (stream = stdout) => clearLine(stream); cursorTo(stream, 0); @

@verbose = @v = if verbose? then createWriter VERBOSE, styler.verbose else => @

