Sha256: 8ca965f5cff8ad98e85b1389e8f4b63cc6b7459a94bdb58ea540e2622d0085aa

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "../base"

module Neetob
  class CLI
    module Github
      module Labels
        class DeleteAll < Base
          attr_accessor :apps, :sandbox

          def initialize(apps, sandbox = false)
            super()
            @apps = apps
            @sandbox = sandbox
          end

          def run
            matching_apps = find_all_matching_apps(apps, :github, sandbox)
            matching_apps.each do |app|
              ui.info("\n Working on #{app} repo \n")
              begin
                labels = client.labels(app)
                labels.each do |label|
                  delete_label(app, label)
                end
              rescue StandardError => e
                ExceptionHandler.new(e).process
              end
            end
          end

          private

            def delete_label(app, label_details)
              if client.delete_label!(app, label_details[:name])
                ui.success("The \"#{label_details[:name]}\" label deleted successfully")
              else
                ui.error("The \"#{label_details[:name]}\" label can't be deleted. Please try again")
              end
            end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neetob-0.1.2 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.1.1 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.1.0 lib/neetob/cli/github/labels/delete_all.rb