 util      = require 'util'
 clone     = require 'clone'
 deepEqual = require './deep-equal'
+basename  = require('path').basename
 
 class Bebopt
   constructor: (@app) ->
-    @app ?= 'bebopt'
-    @_long = {}
-    @_short = {}
+    @app ?= basename(process.argv[1])
+    @_options = []
     @_parent = null
     # XXX for the people; lol, that is this is a protected copy of `argv'
     @_raw = process.argv
     @_cooked = []
     @_eaten = {}
     @usage = undefined
+    @_help = []
 
   _beatError: (parent, name) ->
     switch parent

  [ 'shortBeat', 'longBeat' ].forEach((funcName) =>
    listName = funcName.replace(/Beat/, '')
    return _makeFun(@, funcName, (_name, fn) ->
      # namespace err.. context injection ;)
      self = @
      { op, name } = self._makeOpt(_name)
      self._beatError(listName, name)

      if fn is undefined
        self._parent.type ?= op
        self["_#{listName}"][name] = self._parent
        self["_#{listName}"][name].names.push(name)
        self["_#{listName}"][name].list.push(listName)
      else
        self["_#{listName}"][name] =
          cb: fn
          type: op
          names: []
          list: []
        self["_#{listName}"][name].names.push(name)
        self["_#{listName}"][name].list.push(listName)
      self._parent = self["_#{listName}"][name]
      return self))

  help: (text) =>

      name: name
    }

  # creates a function as a prototype of `context'.
  # can be used to mass-produce class methods
  `function _makeFun(context, name, cb) {
    context.prototype[name] = cb;
    return context;
