     for question, answer of info.trial.survey
       survey += "#{question} – \"#{answer}\"\n"
     console.log "
-      -------------------------------------------------------------------------
-      \nFilename: #{filename}\n
       \nName:     #{info.trial.info.firstname} #{info.trial.info.lastname}
       \nEmail:    #{info.trial.info.email}
       \nAge:      #{info.trial.info.age}

        if datum is ''
          data.splice i, 1
      cb(null, data, filename)
  ], done



displayTrialInfo = (err, data, filename) ->
  if err
    console.error err
    return
  info = extractEvents('participant end', data)
  if info.length is 0
    console.error "
    -------------------------------------------------------------------------
    \nFilename: #{filename}\n
    \nNo participant information found.\n
    "
  else

      "


##
# Displays extracted event data.
displayExtractedEvents = (data, filename, options) ->
  events = extractEvents data, options

  if options.json
    for e, i in events
      events[i] = JSON.stringify(e)

  else if options.csv
    if events.length > 0
      labels = []
      for k, v of events[0]
        labels.push k
      console.log labels.join ','
      for e, i in events
        evt = []
        for k, v of events[i]
          evt.push v
        events[i] = evt.join ','

  if options.count
    console.log events.length
  else
    console.log events.join '\n'



displayExperimentInfo = (data, filename, options) ->
  times = collectExperimentTimes data, filename, options

  displayHeader filename

  for e of times
    for input,v of times[e]
      console.log mapExperimentNames(e), mapInputNames(v.input), moment.duration(v.duration).asSeconds()



info = (files, options) ->
  for file in files
    if options.experiment
      parseLogFile file, displayExperimentInfo, options
    else
      parseLogFile file, displayTrialInfo, options



extract = (files, options) ->
  for file in files
    parseLogFile file, displayExtractedEvents, options



parseArgs = (files..., options) ->

  if options.info
    info files, options

  if options.display
    extract files, options



program
  .version('0.0.1')
  .usage('<log> [logs...]')
  .option('-a, --analyze', 'perform log analysis')
  .option('-i, --info', 'ouput formatted information')
  .option('-D, --display', 'extract and display event information')
  .option('-x, --experiment', 'include experiment events')
  .option('-l, --load', 'include load events')
  .option('-L, --unload', 'include unload events')
  .option('-m, --mouse-move', 'include mouse move events')
  .option('-d, --mouse-down', 'include mouse down events')
  .option('-u, --mouse-up', 'include mouse up events')
  .option('-c, --mouse-click', 'include mouse click events')
  .option('-g, --gaze', 'include gaze events')
  .option('-b, --blink', 'include blink events')
  .option('-f, --fixation', 'include fixation events')
  .option('-F, --fixation-end', 'include fixation-end events')
  .option('-C, --count', 'prints the count of the cooresponding events')
  .option('-j, --json', 'print output as JSON')
  .option('-s, --csv', 'print output as CSV')
  .action(parseArgs)

program.parse(process.argv)
