Sha256: 54d450193a9f80595e74037f32f69ccc1e6c088de0077ca4d20297efc4bb6711

Contents?: true

Size: 1.29 KB

Versions: 88

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "../base"

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

          def initialize(repos, labels, sandbox = false)
            super()
            @labels = labels
            @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("\nDeleting labels from #{repo} repo \n")
              labels.each do |label|
                begin
                  check_if_label_exist!(repo, label)
                  delete_label(repo, label)
                rescue Octokit::NotFound
                  ui.say(" ↳The repo doesn't have the label \"#{label}\"")
                end
              end
            end
          end

          private

            def check_if_label_exist!(repo, label)
              client.label(repo, label)
            end

            def delete_label(repo, label)
              if client.delete_label!(repo, label)
                ui.success(" ↳The \"#{label}\" label deleted successfully")
              end
            end
        end
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
neetob-0.5.6 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.5 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.4 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.3 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.2 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.1 lib/neetob/cli/github/labels/delete.rb
neetob-0.5.0 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.37 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.36 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.35 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.34 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.33 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.32 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.31 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.30 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.28 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.27 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.26 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.24 lib/neetob/cli/github/labels/delete.rb
neetob-0.4.23 lib/neetob/cli/github/labels/delete.rb