Class: Libis::RosettaChecker::SubCommand
- Inherits:
-
Object
- Object
- Libis::RosettaChecker::SubCommand
- Defined in:
- lib/libis/rosetta_checker/sub_command.rb
Direct Known Subclasses
Class Method Summary collapse
- .command ⇒ Object
- .help ⇒ Object
- .options(*argv) ⇒ Object
- .options_class ⇒ Object
- .parse_options(argv) ⇒ Object
- .run ⇒ Object
- .short_desc ⇒ Object
- .subcommands ⇒ Object
Class Method Details
.command ⇒ Object
10 11 12 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 10 def self.command raise RuntimeError, 'Method should be overwritten' end |
.help ⇒ Object
18 19 20 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 18 def self.help self.('-h') end |
.options(*argv) ⇒ Object
22 23 24 25 26 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 22 def self.(*argv) argv = ARGV if argv.empty? @config ||= self..new "#{RosettaChecker.main_command} #{self.command}" (argv) end |
.options_class ⇒ Object
14 15 16 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 14 def self. raise RuntimeError, 'Method should be overwritten' end |
.parse_options(argv) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 28 def self.(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 ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 38 def self.run self. 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 ⇒ Object
6 7 8 |
# File 'lib/libis/rosetta_checker/sub_command.rb', line 6 def self.short_desc raise RuntimeError, 'Method should be overwritten' end |
.subcommands ⇒ Object
55 56 57 |
# 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 |