                          UsageMessageError)
     result = parse_expr(tokens, options)
     if tokens.current() is not null
-        raise tokens.error('unexpected ending: %r' % ' '.join(tokens))
+        raise tokens.error('unexpected ending: ' + tokens.join(' '))
     return new Required(result)
 
 

    (Option.parse('-' + s) for s in doc.split(/^ *-|\n *-/)[1..])

printable_usage = (doc, name) ->
    if usage = (/\s*usage:\s*/i).exec(doc)[0]
        usage = usage.replace(/^\s+/, '')
        indent = '\n' + /(^)?[^\n]*$/.exec(usage)[0].replace(/./g, (c) ->
           return (if c is '\t' then '\t' else ' '))
        uses = doc.substr(usage.length).split(/\n\s*\n/)[0].split('\n')
        uses = (u.replace /^\s+|\s+$/, '' for u in uses)
        if name
            uses = (u.replace /^[^\s]+/, name for u in uses)
        return usage + uses.join(indent)
    else
        throw new UsageMessageError("the first word in the usage should be usage.")

formal_usage = (printable_usage) ->
    pu = printable_usage.split()[1..]  # split and drop "usage:"

print = () -> console.log.apply(@, [].slice.call(arguments))

class UsageMessageError extends Error
    constructor: (message) ->
