# frozen_string_literal: true require "thor" require_relative "list" require_relative "show" require_relative "upsert" require_relative "delete_all" require_relative "delete" require_relative "update" require_relative "../../sub_command_base" module Neetob class CLI module Github module Labels class Commands < SubCommandBase class_option :repos, type: :array, aliases: "-r", desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\"" class_option :all_neeto_repos, type: :boolean, aliases: "--all", default: false, desc: "Use this flag for working with all neeto repos" desc "list", "List all the labels in the Github repos" def list List.new(options[:repos], options[:sandbox], options[:all_neeto_repos]).run end desc "show", "Show details about the given label in the Github repos" option :name, type: :string, aliases: "-n", required: true, desc: "Name of the label" def show Show.new(options[:repos], options[:name], options[:sandbox], options[:all_neeto_repos]).run end desc "upsert", "Create and update labels in the Github repos" option :path, type: :string, aliases: "-p", desc: "The JSON file path which has a list of all the required labels. Each label should have name. The color and description are optional" option :name, type: :string, desc: "Name of the label you want to upsert" option :color, type: :string, desc: "Color of the label you want to upsert" option :description, type: :string, desc: "Description of the label you want to upsert" def upsert Upsert.new( options[:repos], options[:path], options[:sandbox], options[:all_neeto_repos], options[:name], options[:color], options[:description]).run end desc "delete_all", "Delete all the labels from the Github repos" def delete_all DeleteAll.new(options[:repos], options[:sandbox], options[:all_neeto_repos]).run end desc "delete", "Delete some labels from the Github repos" option :labels, type: :array, required: true, desc: "Labels you want to delete from the repos." def delete Delete.new(options[:repos], options[:labels], options[:sandbox], options[:all_neeto_repos]).run end desc "update", "Update a label name in Github repos" option :old_name, type: :string, required: true, desc: "Current label name which needs to be updated" option :new_name, type: :string, required: true, desc: "New name for the updated label" def update Update.new( options[:repos], options[:old_name], options[:new_name], options[:sandbox], options[:all_neeto_repos]).run end end end end end end