import { logError } from 'log'
import { startHandler } from './start-handler'
import { stopHandler } from './stop-handler'
import { statusHandler } from './status-handler'
import { deployHandler } from './deploy-handler'

export const runCliCommand = ({ name, args }) => {

  if (!name) return logError({ message: 'No command provided' })

  const commandHandler = {
    start: startHandler,
    stop: stopHandler,
    status: statusHandler,
    deploy: deployHandler
  }[name]

  if (!commandHandler) {
    return logError({ message: 'Command not implemented, did you spell it correctly?' })
  }

  commandHandler(args)
}
