Sha256: 42db620361d01980b9d98887a303dc7e943f0ca75351e1583bed842d170e9955

Contents?: true

Size: 1.25 KB

Versions: 58

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "../base"

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

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

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

          private

            def delete_label(repo, label_details)
              if client.delete_label!(repo, 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

58 entries across 58 versions & 1 rubygems

Version Path
neetob-0.4.10 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.9 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.8 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.7 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.6 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.5 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.4 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.3 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.2 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.1 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.4.0 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.3.2 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.3.1 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.3.0 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.2.7 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.2.6 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.2.5 lib/neetob/cli/github/labels/delete_all.rb
neetob-0.2.4 lib/neetob/cli/github/labels/delete_all.rb