Added silent option.

This commit is contained in:
Dennis Boeckmann 2013-08-27 17:29:51 +02:00
parent e79f969b93
commit ad8687f166
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,7 @@ It browses the repository and outputs html page with statistics.
f, [--from=FROM] # Commit from where statistics should start.
t, [--to=TO] # Commit where statistics should stop.
# Default: HEAD
s, [--silent] # Silent mode. Don't output anything.
#### Start generator with default settings

View File

@ -8,12 +8,17 @@ class GitStats::CLI < Thor
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.'
option :silent, :aliases => :s, :type => :boolean, :desc => 'Silent mode. Don\'t output anything.'
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}" }
if options[:silent]
g.add_command_observer { |command, result| }
else
g.add_command_observer { |command, result| puts "#{command}" }
end
}.render_all
end