Sha256: aaee201801b2ed2c32c0de571a51ea69ce6b7e7824ae90495197a71fffd510db

Contents?: true

Size: 924 Bytes

Versions: 14

Compression:

Stored size: 924 Bytes

Contents

#!/bin/env ruby

require "Getopt/Declare"

#  In the next example, only the <tt>-a</tt> and <tt>-b</tt> parameters may be clustered.
#  The <tt>-bu</tt> parameter is excluded because it consists of more than one
#  letter, whilst the <tt>-c</tt> and <tt>-d</tt> parameters are excluded because they
#  take (or may take, in <tt>-d</tt>'s case) a variable. The <tt>-e[xec]</tt> parameter
#  is excluded because it may take a trailing punctuator (<tt>[xec]</tt>).
#
#  By comparison, if the directive had been <tt>[cluster: flags]</tt>, then
#  <tt>-bu</tt> _could_ be clustered, though <tt>-c</tt>, <tt>-d</tt> and <tt>-e[xec]</tt> would
#  still be excluded since they are not "pure flags").
#

args = Getopt::Declare.new( <<-'EOSPEC' )

  		-a		Append mode
  		-b		Back-up mode
  		-bu		[ditto]
  		-c <file>	Copy mode
  		-d [<file>]	Delete mode
  		-e[xec]		Execute mode

  		[cluster:singles]
EOSPEC

print args.inspect

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
getopt-declare-1.32 samples/cmdline_singles.rb
getopt-declare-1.31 samples/cmdline_singles.rb
getopt-declare-1.30 samples/cmdline_singles.rb
getopt-declare-1.29 samples/cmdline_singles.rb
getopt-declare-1.13 samples/cmdline_singles.rb
getopt-declare-1.21 samples/cmdline_singles.rb
getopt-declare-1.26 samples/cmdline_singles.rb
getopt-declare-1.22 samples/cmdline_singles.rb
getopt-declare-1.23 samples/cmdline_singles.rb
getopt-declare-1.25 samples/cmdline_singles.rb
getopt-declare-1.20 samples/cmdline_singles.rb
getopt-declare-1.27 samples/cmdline_singles.rb
getopt-declare-1.12 samples/cmdline_singles.rb
getopt-declare-1.28 samples/cmdline_singles.rb