mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
commit
181701546e
4 changed files with 49 additions and 24 deletions
37
README.md
37
README.md
|
@ -20,8 +20,43 @@ It browses the repository and outputs html page with statistics.
|
|||
|
||||
### Generator
|
||||
|
||||
#### Print help
|
||||
|
||||
$ git_stats
|
||||
<follow instructions on the screen>
|
||||
Commands:
|
||||
git_stats generate # Generates the statistics of a repository
|
||||
git_stats help [COMMAND] # Describe available commands or one specific command
|
||||
|
||||
#### Print help of the generate command
|
||||
|
||||
$ git_stats help generate
|
||||
Usage:
|
||||
git_stats generate
|
||||
|
||||
Options:
|
||||
p, [--path=PATH] # Path to repository from which statistics should be generated.
|
||||
# Default: .
|
||||
o, [--output=OUTPUT] # Output path where statistics should be written.
|
||||
# Default: ./git_stats
|
||||
l, [--language=LANGUAGE] # Language of written statistics.
|
||||
# Default: en
|
||||
f, [--from=FROM] # Commit from where statistics should start.
|
||||
t, [--to=TO] # Commit where statistics should stop.
|
||||
# Default: HEAD
|
||||
|
||||
#### Start generator with default settings
|
||||
|
||||
$ git_stats generate
|
||||
git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD | grep -v commit
|
||||
git shortlog -se HEAD
|
||||
...
|
||||
|
||||
#### Start generator with some parameters in long and short form.
|
||||
|
||||
$ git_stats generate -o stats --langugage de
|
||||
git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD | grep -v commit
|
||||
git shortlog -se HEAD
|
||||
...
|
||||
|
||||
### API usage example
|
||||
|
||||
|
|
|
@ -7,5 +7,4 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
|||
# start up the CLI
|
||||
require "git_stats/cli"
|
||||
|
||||
cli = GitStats::CLI.new
|
||||
cli.start
|
||||
GitStats::CLI.start(ARGV)
|
||||
|
|
|
@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
|
|||
gem.add_dependency('haml')
|
||||
gem.add_dependency('lazy_high_charts')
|
||||
gem.add_dependency('i18n')
|
||||
gem.add_dependency('highline')
|
||||
gem.add_dependency('thor')
|
||||
end
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require "git_stats"
|
||||
require "highline/import"
|
||||
require "thor"
|
||||
|
||||
class GitStats::CLI
|
||||
class GitStats::CLI < Thor
|
||||
option :path, :aliases => :p, :default => '.', :desc => 'Path to repository from which statistics should be generated.'
|
||||
option :output, :aliases => :o, :default => './git_stats', :desc => 'Output path where statistics should be written.'
|
||||
option :language, :aliases => :l, :default => 'en', :desc => 'Language of written statistics.'
|
||||
option :from, :aliases => :f, :desc => 'Commit from where statistics should start.'
|
||||
option :to, :aliases => :t, :default => 'HEAD', :desc => 'Commit where statistics should stop.'
|
||||
|
||||
def start
|
||||
|
||||
repo_path = ask("Repo path? ") { |q|
|
||||
q.default = "."
|
||||
q.validate = lambda { |p| GitStats::Validator.new.valid_repo_path?(p) }
|
||||
q.responses[:not_valid] = "Given path is not a git repository, try again"
|
||||
}
|
||||
|
||||
out_path = ask("Output dir? ") { |q| q.default = "./git_stats" }
|
||||
I18n.locale = ask("Language? ") { |q| q.default = "en"; q.answer_type = Symbol }
|
||||
specify_range = agree("Want to specify commits range? ") { |q| q.default = "no" }
|
||||
|
||||
if specify_range
|
||||
first_commit_sha = ask("Starting commit sha? ") { |q| q.default = nil }
|
||||
last_commit_sha = ask("Ending commit sha? ") { |q| q.default = "HEAD" }
|
||||
end
|
||||
|
||||
GitStats::Generator.new(repo_path, out_path, first_commit_sha, last_commit_sha) { |g|
|
||||
desc 'generate', 'Generates the statistics of a repository'
|
||||
def generate
|
||||
I18n.locale = options[:language]
|
||||
GitStats::Generator.new(options[:path], options[:output], options[:from], options[:to]) { |g|
|
||||
g.add_command_observer { |command, result| puts "#{command}" }
|
||||
}.render_all
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue