lib/thor/parser/arguments.rb in thor-0.13.6 vs lib/thor/parser/arguments.rb in thor-0.13.7
- old
+ new
@@ -49,10 +49,15 @@
@assigns
end
private
+ def no_or_skip?(arg)
+ arg =~ /^--(no|skip)-([-\w]+)$/
+ $2
+ end
+
def last?
@pile.empty?
end
def peek
@@ -112,11 +117,11 @@
array << shift
end
array
end
- # Check if the peel is numeric ofrmat and return a Float or Integer.
+ # Check if the peek is numeric format and return a Float or Integer.
# Otherwise raises an error.
#
def parse_numeric(name)
return shift if peek.is_a?(Numeric)
@@ -125,13 +130,19 @@
end
$&.index('.') ? shift.to_f : shift.to_i
end
- # Parse string, i.e., just return the current value in the pile.
+ # Parse string:
+ # for --string-arg, just return the current value in the pile
+ # for --no-string-arg, nil
#
def parse_string(name)
- shift
+ if no_or_skip?(name)
+ nil
+ else
+ shift
+ end
end
# Raises an error if @non_assigned_required array is not empty.
#
def check_requirement!