class Libis::RosettaChecker::SubCommand

Public Class Methods

command() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 10
def self.command
  raise RuntimeError, 'Method should be overwritten'
end
help() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 18
def self.help
  self.options('-h')
end
options(*argv) click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 22
def self.options(*argv)
  argv = ARGV if argv.empty?
  @config ||= self.options_class.new "#{RosettaChecker.main_command} #{self.command}"
  parse_options(argv)
end
options_class() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 14
def self.options_class
  raise RuntimeError, 'Method should be overwritten'
end
parse_options(argv) click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 28
def self.parse_options(argv)
  OptionParser.new do |opts|
    @config.define opts
    opts.on '-h', '--help', 'Show this help' do
      puts opts
      exit
    end
  end.order!(argv)
end
run() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 38
def self.run
  self.options
  instance = self.new(@config)
  instance.run(ARGV)
rescue OptionParser::ParseError => e
  puts "ERROR: #{e.message}"
  puts ''
  self.help
rescue StandardError => e
  $stderr.puts "ERROR: #{e.message} @ #{e.backtrace.first}"
    ap e.backtrace
rescue Interrupt
  $stderr.puts "ERROR: Interrupted."
ensure
    instance.finalize if instance
end
short_desc() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 6
def self.short_desc
  raise RuntimeError, 'Method should be overwritten'
end
subcommands() click to toggle source
# File lib/libis/rosetta_checker/sub_command.rb, line 55
def self.subcommands
  Hash[ObjectSpace.each_object(Class).select {|klass| klass < self}.map {|klass| [klass.command, klass]}]
end