class Gistory::Cli::Main

Public Class Methods

new(repo_path:, args:, io: Gistory::Cli::Io.new) click to toggle source
# File lib/gistory/cli/main.rb, line 6
def initialize(repo_path:, args:, io: Gistory::Cli::Io.new)
  @repo_path = repo_path
  @args = args
  @io = io
end

Public Instance Methods

run() click to toggle source
# File lib/gistory/cli/main.rb, line 12
def run
  repo = GitRepo.new(path: @repo_path)
  parser = Cli::ArgParser.new(args: @args, io: @io)
  config = parser.parse
  history(repo, config.gem_name)
rescue Gistory::ParserError => e
  @io.error e.message
  @io.puts parser
rescue Gistory::Error => e
  @io.error e.message
end

Private Instance Methods

history(repo, gem_name) click to toggle source
# File lib/gistory/cli/main.rb, line 26
def history(repo, gem_name)
  changes = ChangeLog.new(repo: repo).changelog_for_gem(gem_name)

  if changes.empty?
    raise(Gistory::Error, "Gem '#{gem_name}' not found in lock file, maybe a typo?")
  end

  if Gistory.config.output_commit_hashes_only?
    print_commit_hashes_only(changes)
  else
    print_full_output(gem_name, changes)
  end
end
print_change_history(changes) click to toggle source
print_commit_hashes_only(changes) click to toggle source
print_configuration_info() click to toggle source
print_full_output(gem_name, changes) click to toggle source