argser 1.6 → 1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/argser/parser.rb +11 -7
- metadata +1 -1
data/lib/argser/parser.rb
CHANGED
@@ -73,10 +73,7 @@ module Argser
|
|
73
73
|
#Invoke all callbacks
|
74
74
|
invoke_callbacks
|
75
75
|
rescue ParserError => error
|
76
|
-
|
77
|
-
puts error.message
|
78
|
-
puts @options[:info] unless @options[:info].empty?
|
79
|
-
exit
|
76
|
+
show_error error.message
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
@@ -124,9 +121,11 @@ module Argser
|
|
124
121
|
exit
|
125
122
|
end
|
126
123
|
|
127
|
-
#
|
128
|
-
def
|
129
|
-
|
124
|
+
#Print the error and how to find more information
|
125
|
+
def show_error(error)
|
126
|
+
puts error
|
127
|
+
puts @options[:info] unless @options[:info].empty?
|
128
|
+
exit
|
130
129
|
end
|
131
130
|
|
132
131
|
private
|
@@ -288,6 +287,11 @@ module Argser
|
|
288
287
|
@remaining[:callback].call(@remaining[:value], !@remaining[:given])
|
289
288
|
end
|
290
289
|
|
290
|
+
#Raise an error
|
291
|
+
def raise_error(message, token='', value='')
|
292
|
+
raise ParserError.new(message || @options[:fatal], token, value)
|
293
|
+
end
|
294
|
+
|
291
295
|
#Parser errors used to display errors ($p is replaced by the parameter used by the user, $v is replaced by the value given)
|
292
296
|
class ParserError < Exception
|
293
297
|
attr_reader :message
|