lib/rake/toolkit_program/command_option_parser.rb
##
# Explicitly define capture of positional (non-option) arguments
#
# When parsing into a Hash, the default is to store the Array of
# remaining positional arguments in the +nil+ key.  This method
# overrides that behavior by either specifying a specific key to
# use or by specifying a block to call with the positional arguments,
# which is much more useful when accumulating arguments to a non-Hash
# object.  Passing +key+ or a block are mutually exclusive.
#
# +precapture_dest_array+ can be set to +true+ to cause the capture
# to take place before the positional arguments are accumulated.  In this
# case, the Array object yielded to the block (if this method is called
# with a block) _must_ be stored, as it will be the recipient of all
# positional arguments.  In any case, when this option is passed to this
# method, capture behavior for the (empty) Array into which the
# positional arguments will be stored is carried out _before_ option
# parsing, and values are (after any transformation dictated by
# #map_positional_args) stored in the positional arguments Array; there
# is no option to store positionals for consumption by the command task
# code in anything other than an Array.  Note that the Array into which
# arguments are captured <i>is not</i> the same array either passed to
# or returned from the #parse! (or #parse, for that matter) method.
#
# If multiple calls to this method are made, the last one is the one
# that defines the behavior.
#
# +key+:: Key under which positionals shall be accumulated in a Hash
# +precapture_dest_array+:: Capture before argument accumulation
#
Explicitly define capture of positional (non-option) arguments
When parsing into a Hash, the default is to store the Array of
remaining positional arguments in the +nil+ key.  This method
overrides that behavior by either specifying a specific key to
use or by specifying a block to call with the positional arguments,
which is much more useful when accumulating arguments to a non-Hash
object.  Passing +key+ or a block are mutually exclusive.

+precapture_dest_array+ can be set to +true+ to cause the capture
to take place before the positional arguments are accumulated.  In this
case, the Array object yielded to the block (if this method is called
with a block) _must_ be stored, as it will be the recipient of all
positional arguments.  In any case, when this option is passed to this
method, capture behavior for the (empty) Array into which the
positional arguments will be stored is carried out _before_ option
parsing, and values are (after any transformation dictated by
map_positional_args) stored in the positional arguments Array; there
is no option to store positionals for consumption by the command task
code in anything other than an Array.  Note that the Array into which
arguments are captured is not the same array either passed to
or returned from the #parse. (or #parse, for that matter) method.

If multiple calls to this method are made, the last one is the one
that defines the behavior.

+key+:: Key under which positionals shall be accumulated in a Hash
+precapture_dest_array+:: Capture before argument accumulation
Explicitly define capture of positional ( non - option ) arguments When parsing into a Hash the default is to store the Array of remaining positional arguments in the + nil + key . This method overrides that behavior by either specifying a specific key to use or by specifying a block to call with the positional arguments which is much more useful when accumulating arguments to a non - Hash object . Passing + key + or a block are mutually exclusive . + precapture_dest_array + can be set to + true + to cause the capture to take place before the positional arguments are accumulated . In this case the Array object yielded to the block ( if this method is called with a block ) _must_ be stored as it will be the recipient of all positional arguments . In any case when this option is passed to this method capture behavior for the ( empty ) Array into which the positional arguments will be stored is carried out _before_ option parsing and values are ( after any transformation dictated by map_positional_args ) stored in the positional arguments Array ; there is no option to store positionals for consumption by the command task code in anything other than an Array . Note that the Array into which arguments are captured is not the same array either passed to or returned from the #parse . ( or #parse for that matter ) method . If multiple calls to this method are made the last one is the one that defines the behavior . + key + :: Key under which positionals shall be accumulated in a Hash + precapture_dest_array + :: Capture before argument accumulation
def capture_positionals(key=nil, precapture_dest_array: false, &blk)
        if blk && !key.nil?
          raise ArgumentError, "either specify key or block"
        end
        @positionals_key = key
        @positionals_capture = blk
        @precapture_positionals_array = precapture_dest_array
      end
def capture_positionals ( key = nil , precapture_dest_array : false , & blk ) if blk && ! key . nil? raise ArgumentError , "either specify key or block" end @positionals_key = key @positionals_capture = blk @precapture_positionals_array = precapture_dest_array end
Explicitly define capture of positional (non-option) arguments
When parsing into a Hash, the default is to store the Array of
remaining positional arguments in the +nil+ key.
Explicitly define capture of positional ( non - option ) arguments When parsing into a Hash the default is to store the Array of remaining positional arguments in the + nil + key .
key
<not_specific>
precapture_dest_array
<not_specific>
blk
<not_specific>