mirror of
https://github.com/tomgi/git_stats.git
synced 2024-11-19 01:50:39 +01:00
40 lines
787 B
Ruby
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
|