require "devops-client/handler/handler"
require "devops-client/options/chef_options"
require "json"
require "devops-client/output/chef"

class Chef < Handler

  output_with Output::Chef

  def initialize(host, def_options={})
    @host, @options = host, def_options
    @options_parser = ChefOptions.new(ARGV, def_options)
  end

  def handle
    @command, @options, @args = @options_parser.parse_options_for!
    extract_parameters
    case @command
    when :bootstrap_templates
      bootstrap_templates_handler
    when :tags_list
      tags_list_handler
    end
    output
  end

  def bootstrap_templates_handler
    @list = get("/chef/bootstrap_templates")
  end

  def tags_list_handler
    @list = get("/chef/tags/#{@cm_name}")
  end

end

