     win.loadUrl url
     win.show()
     win
-
-
-browserMain = new BrowserMain
-
-delegate.browserMainParts.preMainMessageLoopRun = ->
-  Menu.setApplicationMenu browserMain.menu
-
-  new AtomWindow
-    bootstrapScript: 'window-bootstrap',
-    resourcePath: browserMain.resourcePath

app = require 'app'
delegate = require 'atom_delegate'
path = require 'path'
BrowserWindow = require 'browser_window'
Menu = require 'menu'
ipc = require 'ipc'
dialog = require 'dialog'
optimist = require 'optimist'

class BrowserMain
  windowState: null
  resourcePath: null

  constructor: ->
    @windowState = {}

    @setupJavaScriptArguments()
    @parseCommandLine()
    @buildApplicationMenu()
    @setupNodePaths()
    @handleEvents()

  setupJavaScriptArguments: ->
    app.commandLine.appendSwitch 'js-flags', '--harmony_collections'

  parseCommandLine: ->
    modifiedArgv = ['node'].concat(process.argv) # optimist assumes the first arg will be node
    args = optimist(modifiedArgv).argv
    @resourcePath = args['resource-path']

  buildApplicationMenu: ->
    atomMenu =
      label: 'Atom'
      submenu:
        { label: 'About Atom', selector: 'orderFrontStandardAboutPanel:' }
        { type: 'separator' }
        { label: 'Hide Atom Shell', accelerator: 'Command+H', selector: 'hide:' }

      dialog.openFolder currentWindow, {}, (result, paths...) =>
        new AtomWindow
          bootstrapScript: 'window-bootstrap',
          resourcePath: resourcePath

class AtomWindow
  @windows = []
