class Shaf::Command::Base
Attributes
args[R]
options[R]
Public Class Methods
exit_with_error(msg, status)
click to toggle source
# File lib/shaf/command/base.rb, line 26 def exit_with_error(msg, status) STDERR.puts msg exit status end
identifier(*ids)
click to toggle source
# File lib/shaf/command/base.rb, line 18 def identifier(*ids) @identifiers = ids.flatten end
inherited(child)
click to toggle source
# File lib/shaf/command/base.rb, line 14 def inherited(child) Factory.register(child) end
new(*args, **options)
click to toggle source
# File lib/shaf/command/base.rb, line 34 def initialize(*args, **options) @args = args.dup @options = options parse_options! end
options(option_parser, options)
click to toggle source
# File lib/shaf/command/base.rb, line 31 def options(option_parser, options); end
usage(str = nil, &block)
click to toggle source
# File lib/shaf/command/base.rb, line 22 def usage(str = nil, &block) @usage = str || block end
Private Instance Methods
common_options(parser, _options)
click to toggle source
# File lib/shaf/command/base.rb, line 51 def common_options(parser, _options) parser.on('--trace', 'Show backtrace on command failure') end
parse_options!()
click to toggle source
# File lib/shaf/command/base.rb, line 42 def parse_options! parser = OptionParser.new common_options(parser, options) self.class.options(parser, options) parser.parse!(args) rescue OptionParser::InvalidOption => e raise ArgumentError, e.message end