-{exec, spawn} = require 'child_process'
+{spawn} = require 'child_process'
 Promise = require 'bluebird'
-{log, warn, error} = require './logger'
 {parsePath} = require './util'
 Stream = require './executable/stream'
 {InvalidExecutablePathError} = require './error'

                    @process = process
                    resolve process

                log 'Executable', 'process wired'

                process.stdout
                    .pipe new Stream.Rectify
                    .pipe new Stream.ParseSExpr
                    .pipe new Stream.ParseCommand @core
                log 'Executable', 'process.stdout stream established'
            .catch (e) -> error e

    ################
    #   COMMANDS   #

    validateExecutablePath: (path) -> new Promise (resolve, reject) =>
        path = parsePath path

        process = spawn path, ['-V']

        process.on 'error', (error) =>
            reject new InvalidExecutablePathError error

        process.stdout.once 'data', (data) =>
            if /^Agda/.test data.toString()
                resolve path
            else
                reject new InvalidExecutablePathError data.toString()

    # keep banging the user until we got the right path
    queryExecutablePathUntilSuccess: (path) ->
        @core.panel.setContent "Agda executable not found: \"#{path}\"", [], 'warning', 'path of executable here'
        @core.panel.query()
            .then (path) =>
                path = parsePath path
                @validateExecutablePath path
                    .then (path) => path
                    .catch InvalidExecutablePathError, => @queryExecutablePathUntilSuccess path
            .then (path) =>
                atom.config.set 'agda-mode.executablePath', path
                return path
            .catch InvalidExecutablePathError, =>
                @queryExecutablePathUntilSuccess path

    # get executable path from config, query the user if failed
