   # that arg is added to the option's object
   # within the respective
   # option list, such as `@_long'
-  _catchSpaceDelimArgs: (opt, list, listName) =>
-    @_catchInvalidOpt(opt, listName)
+  _catchSpaceDelimArgs: (opt, list) =>
     if list[opt.arg].type isnt 'flag'
       if opt.optarg is undefined
         @_args.forEach((nonOpt, ind) =>
           if nonOpt.index is (opt.index + 1)
             opt.optarg = nonOpt.arg
             delete @_args[ind])
-        return opt
+    return opt
 
   _catchInvalidOpt: (opt, list) =>
-    console.log list.toString()
-    if opt.arg.length < 2 and @_short[opt.arg] is undefined
+    if list is 'short' and @_short[opt.arg] is undefined
       console.error("#{@app}: invalid option -- '#{opt.arg}'")
       process.exit(1)
-    else if opt.arg.length > 1 and @_long[opt.arg] is undefined
+    else if list is 'long' and @_long[opt.arg] is undefined
       console.error("#{@app}: unrecognized option '--#{opt.arg}'")
       process.exit(1)
 

      dashes = elem.arg.replace(/^(--?).*/, '$1').length # number of dashes
      elem.arg = elem.arg.replace(/^--?(.*)/, '$1')
      if dashes is 2
        elem = @_catchSpaceDelimArgs(elem, @_long, 'long')
      else
        elem = @_catchSpaceDelimArgs(elem, @_short, 'short')

    )

# processes `process.arv' producing two arrays, one containing options,
# their indexes and any arguments passed in the `--OPTION=ARG' fashion,

  parse: () =>
    @_gather()
    @_resolveOpts()
    @_log(@)

module.exports = Bebopt
