#! /usr/bin/env ruby # frozen_string_literal: true require 'deploy_log' start, finish, title, branch, on, week = nil OptionParser.new do |opt| opt.on('-s', '--start=START', 'Start of date range') do |time| start = Time.parse(time) end opt.on('-e', '--end=END', 'End of date range') do |time| finish = Time.parse(time) end opt.on('-o', '--on=ON', 'Merged on a specific date') do |time| on = Time.parse(time) end opt.on('-t', '--title=TITLE', 'Title of the PR you want') do |ti| title = ti end opt.on('-b', '--branch=BRANCH', 'Name of the branch you want') do |br| branch = br end opt.on('-w', '--week=WEEK', 'Get PRs merged during week number X') do |w| week = w end opt.on('-c', '--clean', 'Pull data from api, ignore cache') do system('rm -f /tmp/github-deploys-*.log') Notify.info 'Cleared cache' exit end opt.on('-v', '--version', 'Prints version information') do puts DeployLog::VERSION exit end end.parse! model = DeployLog::Github::Deploys.new return model.merged_during_week(week) if week return model.merged_between(start, finish) if start return model.merged_on(on) if on return model.pr_title(title) if title return model.pr_for_branch(branch) if branch return model.merged_today if title.nil? && branch.nil? && start.nil? && finish.nil? && on.nil?