 #
 # Wrapper for optimise that allows us to clean up the args as they come in.
 getArgs = ->
+  usage = 'Usage: bo [xpath|css]\n\n' +
+    'If no attribute is given, innerHTML, text or a plain string\n' +
+    'will be returned (depending on what is matched)'
   argv = optimist
-    .usage('Usage: bo [xpath|css]')
+    .usage(usage)
+    .alias('a', 'attribute')
+    .default('a', undefined)
     .alias('l', 'loglevel')
     .default('l', 'silent')
     .demand(1)
     .argv
   [ query ] = argv._
   query = query.trim()
+  attribute = argv.attribute?.trim()
   loglevel = argv.loglevel.trim()
   {
     query
+    attribute
     loglevel
   }
 

#
# depending on the query given by the user, we will be getting an html element,
# or a plain old string. This should be handled elegantly.
elToString = (el) ->
  if el.innerHTML?
    log.verbose 'elToString', "Fetching innerHTML from '#{el}'."
    return el.innerHTML.trim()
  else if el.textContent?



# Get the args
{ query, attribute, loglevel } = getArgs()
# Set our default logging level, only log items at this level and higher.
# The default loglevel is err - only show errors
log.level = loglevel
