       'tokamak:clean': => @attachCargo('clean')
       'tokamak:build-run': => @attachCargo('build-run')
       'tokamak:rebuild': => @attachCargo('rebuild')
-      'tokamak:run': => @attachCargo('bin')
+      'tokamak:run': => @attachCargo('run')
 
     @miniEditor.on 'blur', => @close()
     atom.commands.add @element,


  runCommand: (command, args, exit) ->
    new BufferedProcess({command, args, exit})

    @miniEditor.focus()

  attachCargo: (@cmd) ->
    @cargoCmdRunner(@cmd, @cargoCmdExitCallback)

  cargoCmdExitCallback: (@cmd, code) =>
    console.log code
    if code != 0
      atom.notifications.addError("Tokamak: Cargo #{@cmd} failed!", {
        detail: "Cargo #{@cmd} exited with #{code}"
      })
    else
      atom.notifications.addSuccess("Tokamak: Cargo #{@cmd} successful!")

  cargoCmdRunner: (@cmd, callback) ->
    cargoPath = atom.config.get("tokamak.cargoBinPath")
    switch @cmd
      when "build"
          @runCommand(cargoPath, ["build"], exit = (code) => callback(@cmd, code))
      when "clean"
          @runCommand(cargoPath, ["clean"], exit = (code) => callback(@cmd, code))
      when "build-run"
          @runCommand(cargoPath, ["build"], exit = (code) => callback(@cmd, code))
          @runCommand(cargoPath, ["run"], exit = (code) => callback(@cmd, code))
      when "rebuild"
          @runCommand(cargoPath, ["clean"], exit = (code) => callback(@cmd, code))
          @runCommand(cargoPath, ["build"], exit = (code) => callback(@cmd, code))
      when "run"
          @runCommand(cargoPath, ["run"], exit = (code) => callback(@cmd, code))
      else null

  serialize: ->
