argser 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/argser/parser.rb +11 -7
  2. metadata +1 -1
@@ -73,10 +73,7 @@ module Argser
73
73
  #Invoke all callbacks
74
74
  invoke_callbacks
75
75
  rescue ParserError => error
76
- #In case of error, print the reason and how to find more information
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
- #Raise an error
128
- def raise_error(message, token='', value='')
129
- raise ParserError.new(message || @options[:fatal], token, value)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argser
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '1.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: