# frozen_string_literal: true require "thor" require_relative "labels/commands" require_relative "issues/commands" require_relative "search" require_relative "protect_branch" require_relative "login" require_relative "make_pr/commands" require_relative "gems/commands" require_relative "brakeman" module Neetob class CLI module Github class Commands < Thor desc "labels", "Interact with the labels of Github repos" subcommand "labels", Labels::Commands desc "issues", "Interact with the issues of Github repos" subcommand "issues", Issues::Commands desc "make-pr", "Create PRs across multiple Github repos" subcommand "make_pr", MakePr::Commands desc "gems", "Interact with the neeto gems" subcommand "gems", Gems::Commands desc "search", "Find the lines matching the given keyword in the specified file across all the neeto repos" option :repos, type: :array, aliases: "-r", required: true, desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\"" option :keyword, type: :string, aliases: "-k", desc: "Keyword which needs to be searched", required: true option :path, type: :string, aliases: "-p", desc: "Path of the file in which you want to search the given keyword.", required: true option :replace, type: :string, aliases: "-s", desc: "Word with which you want to replace the found instances of the keyword" def search Search.new(options[:repos], options[:keyword], options[:path], options[:replace], options[:sandbox]).run end desc "login", "Update the Github access token by authenticating via browser" def login Login.new end desc "protect_branch", "Protect the specified branch with the given rules" option :branch, type: :string, aliases: "-b", desc: "Name of the branch whose protections rules needs to be updated", required: true option :path, type: :string, aliases: "-p", desc: "The JSON file path which specify all the required rules for branch protection" option :repos, type: :array, aliases: "-r", desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos.", required: true def protect_branch ProtectBranch.new( options[:branch], options[:repos], options[:path], options[:sandbox]).run end desc "brakeman", "Run brakeman on neeto repos & create issues in repos where needed" option :repos, type: :array, aliases: "-r", desc: "Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos.", required: true def brakeman Brakeman.new(options[:repos], options[:sandbox]).run end end end end end