require "devops-client/options/main"

class HandlerFactory

  def self.create cmd, host, auth, def_options
    klass = case cmd
    when ImageOptions::COMMAND_NAME
      require "devops-client/handler/image"
      Image
    when FilterOptions::COMMAND_NAME
      require "devops-client/handler/filter"
      Filter
    when DeployOptions::COMMAND_NAME
      require "devops-client/handler/deploy"
      Deploy
    when ProjectOptions::COMMAND_NAME
      require "devops-client/handler/project"
      Project
    when EnvironmentOptions::COMMAND_NAME
      require "devops-client/handler/environment"
      Environment
    when CategoryOptions::COMMAND_NAME
      require "devops-client/handler/category"
      Category
    when KeyOptions::COMMAND_NAME
      require "devops-client/handler/key"
      Key
    when UserOptions::COMMAND_NAME
      require "devops-client/handler/user"
      User
    when ProviderOptions::COMMAND_NAME
      require "devops-client/handler/provider"
      Provider
    when ServerOptions::COMMAND_NAME
      require "devops-client/handler/server"
      Server
    when ScriptOptions::COMMAND_NAME
      require "devops-client/handler/script"
      Script
    when ChefOptions::COMMAND_NAME
      require "devops-client/handler/chef"
      Chef
    when StackTemplateOptions::COMMAND_NAME
      require "devops-client/handler/stack_template"
      StackTemplate
    when StackOptions::COMMAND_NAME
      require "devops-client/handler/stack"
      Stack
    when RoleOptions::COMMAND_NAME
      require "devops-client/handler/role"
      Role
    else
      Main.new(ARGV, def_options).info
      exit(10)
    end
    service = klass.new(host, def_options)
    service.auth = auth
    service
  end
end
