Exception: Console::Command::UnknownOptionError
- Defined in:
- lib/qualitysmith_extensions/console/command.rb
Overview
# We include a module here so you can define your own help
# command and call #super to utilize this one.
module Help
def help
opts =
s = ""
s << "#{File.basename($0)}\n\n"
unless opts.empty?
s << "OPTIONS\n"
s <<
s << "\n"
end
s << "COMMANDS\n"
s << help_commands
puts s
end
private
def help_commands
help = self.class.help
bufs = help.keys.collect{ |a| a.to_s.size }.max + 3
lines = []
help.each { |cmd, str|
cmd = cmd.to_s
if cmd !~ /^_/
lines << " " + cmd + (" " * (bufs - cmd.size)) + str
end
}
lines.join("\n")
end
def
help = self.class.help
bufs = help.keys.collect{ |a| a.to_s.size }.max + 3
lines = []
help.each { |cmd, str|
cmd = cmd.to_s
if cmd =~ /^_/
lines << " " + cmd.gsub(/_/,'-') + (" " * (bufs - cmd.size)) + str
end
}
lines.join("\n")
end
module ClassMethods
def help( str=nil )
return (@help ||= {}) unless str
@current_help = str
end
def method_added( meth )
if @current_help
@help ||= {}
@help[meth] = @current_help
@current_help = nil
end
end
end
end
include Help
extend Help::ClassMethods
Instance Method Summary collapse
-
#initialize(option_name) ⇒ UnknownOptionError
constructor
A new instance of UnknownOptionError.
- #message ⇒ Object
Constructor Details
#initialize(option_name) ⇒ UnknownOptionError
Returns a new instance of UnknownOptionError.
595 596 597 |
# File 'lib/qualitysmith_extensions/console/command.rb', line 595 def initialize(option_name) @option_name = option_name end |
Instance Method Details
#message ⇒ Object
598 599 600 |
# File 'lib/qualitysmith_extensions/console/command.rb', line 598 def "Unknown option '#{@option_name}'." end |