git_stats/lib/gitstats/cli.rb
2012-10-08 17:58:07 +02:00

40 lines
787 B
Ruby

require "gitstats"
class GitStats::CLI
def self.start(*args)
unless args.size == 2
puts "Wrong number of arguments"
help
else
repo_path, out_path = args
validate(repo_path, out_path)
GitStats::Generator.new(repo_path, out_path).generate
end
end
private
def self.help
puts "Usage: gitstats repo_path output_path"
exit 0
end
def self.validate(repo_path, out_path)
validate_repo(repo_path)
validate_out(out_path)
end
def self.validate_repo(repo_path)
unless Dir.exists?("#{repo_path}/.git")
puts "#{repo_path} is not a git repository"
help
end
end
def self.validate_out(out_path)
unless Dir.exists?("#{out_path}")
puts "#{out_path} doesn't exist"
help
end
end
end