Sha256: 0c5293f2289fea366f140673acdde2f7a94b96958dc67f58d0e65b8d939ff929

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

# -*- encoding : utf-8 -*-
require "git_stats"
require "highline/import"

class GitStats::CLI

  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|
      g.add_command_observer { |command, result| puts "#{command}" }
    }.render_all
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_stats-1.0.7 lib/git_stats/cli.rb
git_stats-1.0.6 lib/git_stats/cli.rb