Exception: OptionParser::ParseError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- OptionParser::ParseError
- Defined in:
- lib/llm/shell/internal/optparse/lib/optparse.rb
Overview
Base class of exceptions from OptionParser.
Direct Known Subclasses
AmbiguousOption, InvalidArgument, InvalidOption, MissingArgument, NeedlessArgument
Constant Summary collapse
- Reason =
Reason which caused the error.
'parse error'- DIR =
File.join(__dir__, '')
Instance Attribute Summary collapse
-
#additional ⇒ Object
Returns the value of attribute additional.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#reason ⇒ Object
Returns error reason.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args, additional: nil) ⇒ ParseError
constructor
:nodoc:.
- #inspect ⇒ Object
-
#message ⇒ Object
(also: #to_s)
Default stringizing method to emit standard error message.
-
#recover(argv) ⇒ Object
Pushes back erred argument(s) to
argv. - #set_backtrace(array) ⇒ Object
- #set_option(opt, eq) ⇒ Object
Constructor Details
#initialize(*args, additional: nil) ⇒ ParseError
:nodoc:
2260 2261 2262 2263 2264 2265 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2260 def initialize(*args, additional: nil) @additional = additional @arg0, = args @args = args @reason = nil end |
Instance Attribute Details
#additional ⇒ Object
Returns the value of attribute additional.
2269 2270 2271 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2269 def additional @additional end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
2267 2268 2269 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2267 def args @args end |
#reason ⇒ Object
Returns error reason. Override this for I18N.
2303 2304 2305 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2303 def reason @reason || self.class::Reason end |
Class Method Details
.filter_backtrace(array) ⇒ Object
2280 2281 2282 2283 2284 2285 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2280 def self.filter_backtrace(array) unless $DEBUG array.delete_if {|bt| bt.start_with?(DIR)} end array end |
Instance Method Details
#inspect ⇒ Object
2307 2308 2309 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2307 def inspect "#<#{self.class}: #{args.join(' ')}>" end |
#message ⇒ Object Also known as: to_s
Default stringizing method to emit standard error message.
2314 2315 2316 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2314 def "#{reason}: #{args.join(' ')}#{additional[@arg0] if additional}" end |
#recover(argv) ⇒ Object
Pushes back erred argument(s) to argv.
2274 2275 2276 2277 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2274 def recover(argv) argv[0, 0] = @args argv end |
#set_backtrace(array) ⇒ Object
2287 2288 2289 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2287 def set_backtrace(array) super(self.class.filter_backtrace(array)) end |
#set_option(opt, eq) ⇒ Object
2291 2292 2293 2294 2295 2296 2297 2298 |
# File 'lib/llm/shell/internal/optparse/lib/optparse.rb', line 2291 def set_option(opt, eq) if eq @args[0] = opt else @args.unshift(opt) end self end |