Class: Pronto::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/pronto/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.is_thor_reserved_word?(word, type) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/pronto/cli.rb', line 9

def is_thor_reserved_word?(word, type)
  return false if word == 'run'
  super
end

Instance Method Details

#listObject



75
76
77
# File 'lib/pronto/cli.rb', line 75

def list
  puts ::Pronto::GemNames.new.to_a
end

#run(path = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pronto/cli.rb', line 48

def run(path = nil)
  gem_names = options[:runner].any? ? options[:runner] : ::Pronto::GemNames.new.to_a
  gem_names.each do |gem_name|
    require "pronto/#{gem_name}"
  end

  formatters = ::Pronto::Formatter.get(options[:formatters])

  commit_options = %i[staged unstaged index]
  commit = commit_options.find { |o| options[o] } || options[:commit]

  repo_workdir = ::Rugged::Repository.discover('.').workdir
  messages = Dir.chdir(repo_workdir) do
    ::Pronto.run(commit, '.', formatters, path)
  end
  if options[:'exit-code']
    error_messages_count = messages.count { |m| m.level != :info }
    exit(error_messages_count)
  end
rescue Rugged::RepositoryError
  puts '"pronto" should be run from a git repository'
rescue Pronto::Error => e
  $stderr.puts "Pronto errored: #{e.message}"
end

#verbose_versionObject



89
90
91
# File 'lib/pronto/cli.rb', line 89

def verbose_version
  puts Version.verbose
end

#versionObject



82
83
84
# File 'lib/pronto/cli.rb', line 82

def version
  puts Version::STRING
end