#!/usr/bin/env ruby require_relative '../lib/pair_see/seer' require_relative '../lib/pair_see/person' require_relative '../lib/pair_see/knowledge_debt' require_relative '../lib/pair_see/card_knowledge_summary' require_relative '../lib/pair_see/pairing_event' require_relative '../lib/pair_see/pair_recency' require 'trollop' opts = Trollop.options do opt :config, 'location of config file, example: ../../config/config.yml', default: 'config/config.yml' opt :after, 'Date since which you want to get commits, in yyyy-mm-dd format', default: '0-1-1' opt :extras, 'See all commits without the name of any dev in them', default: false opt :latest, 'See dates of most recent commits by pairs', default: false opt :recommended, 'See active devs who have not paired (and therefore should)', default: false opt :cards, 'See cards and number of commits on each', default: false opt :cards_by_commits, 'This goes with --cards and sorts by number of commits instead of active card days', default: false opt :cards_per_person, 'See cards for each dev', default: false opt :knowledge_debt, 'Knowledge debt (cards that only one person worked on)', default: false opt :my_pairs, 'Most recent dates of pairing for user', default: false end def run_command(opts) begin config = YAML.load_file(opts[:config]) rescue puts 'Config file not found at: ' + opts[:config] + " See config/config.yml.sample for an example. \n...exiting" exit end options = { names: config['names'].map { |i| PairSee::Person.new(i.split(' ')) }, # TODO: rename "names" to "people" card_prefix: config['card_prefix'], after_date: opts[:after], repo_locations: config['roots'] } seer = PairSee::Seer.new(options) if opts[:extras] seer.commits_not_by_known_pair elsif opts[:latest] seer.all_most_recent_commits elsif opts[:recommended] seer.recommended_pairings elsif opts[:cards] if opts[:cards_by_commits] seer.pretty_card_data_by_commits else seer.pretty_card_data end elsif opts[:cards_per_person] seer.cards_per_person elsif opts[:knowledge_debt] seer.knowledge_debt elsif opts[:my_pairs] seer.pair_recency else seer.all_commits end end puts run_command(opts).join("\n")