bin/branches_without_pulls
#! /usr/bin/env ruby
# frozen_string_literal: true
require 'octokit'
require 'optparse'
require 'yaml'
require_relative '../lib/hubtrics'
parser = Hubtrics::Parser.new(
banner: "Usage: #{File.basename(__FILE__)} [options]",
switches: [
{
switch: :grace_period,
definition: ['--grace-period GRACE_PERIOD', Integer, 'Grace period in days before considering the branch stale']
}
]
)
options = parser.parse(ARGV)
client = Hubtrics.client(options[:client])
report = Hubtrics::Reports::BranchesWithoutPullsReport.new(
client,
repository: options[:repository],
config: options[:github],
options: {
grace_period: options.fetch(:grace_period, 14),
gist: options.fetch(:gist, nil)
}
)
report.generate
gist = report.save_to_gist(options[:gist])
Hubtrics.say("Report was written to:\n#{gist.html_url}", :yellow)