Class: Sumo::CLI

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/sumo/cli.rb

Overview

This class is used to define a CLI.

Instance Method Summary collapse

Instance Method Details

#executeObject

This method is called when the CLI is run.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sumo/cli.rb', line 25

def execute
  if version?
    $stdout.puts Sumo::VERSION
  elsif records?
    search.records.each { |record| $stdout.puts record }
  else
    search.messages.each { |msg| $stdout.puts format_message(msg['_raw']) }
  end
rescue StandardError => ex
  $stderr.puts "#{ex.class}: #{ex.message}"
  exit 1
end