Class: GitFame::Command

Inherits:
Object
  • Object
show all
Includes:
TTY::Option
Defined in:
lib/git_fame/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(argv = ARGV) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/git_fame/command.rb', line 107

def self.call(argv = ARGV)
  cmd = new
  cmd.parse(argv, raise_on_parse_error: true)
  cmd.run
rescue TTY::Option::InvalidParameter, TTY::Option::InvalidArgument => e
  abort e.message
end

Instance Method Details

#runObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/git_fame/command.rb', line 115

def run
  if params[:help]
    puts help
    exit
  end

  if params[:version]
    puts "git-fame v#{GitFame::VERSION}"
    exit
  end

  thread = spinner.run do
    Render.new(result: result, **options(:branch))
  end

  thread.value.call
rescue Dry::Struct::Error => e
  abort e.message
rescue Interrupt
  exit
end