require "devops-client/output/base"

module Output
  class Script < Base

    def table
      headers, rows = create(@data)
      create_table(headers, rows, I18n.t("output.title.script.list"))
    end

    def csv
      headers, rows = create(@data)
      create_csv(headers, rows)
    end

  private
    def create list
      rows = []
      abort(I18n.t("output.not_found.script.list")) if list.nil? or list.empty?
      list.each do |l|
        rows.push [ l ]
      end
      headers = [I18n.t("output.table_header.name")]
      return headers, rows
    end
  end
end
