Class: GitHop::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/githop/command.rb

Class Method Summary collapse

Class Method Details

.run(other_user, date = 1.year.ago) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/githop/command.rb', line 5

def self.run(other_user, date = 1.year.ago)
  config = YAML.load(File.read("#{ENV['HOME']}/.githop.yml"))
  result = GitHop.hop(config, other_user, date)

  if result['rows'].nil?
    $stderr.puts "GitHub Archive query for #{other_user || config['github_user']} had no results."
    $stderr.puts result.inspect
    exit(1)
  end

  result = GitHop.pretty_print(result, other_user)

  if result.count == 0
    puts "No events found, but #{other_user || 'you'} surely had an awesome day nevertheless :)"
  else
    puts result
  end
end