diff options
Diffstat (limited to 'lib/getoptlong.rb')
-rw-r--r-- | lib/getoptlong.rb | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb index 4cfb5fbd27..c5e60ec188 100644 --- a/lib/getoptlong.rb +++ b/lib/getoptlong.rb @@ -12,10 +12,10 @@ # found at http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/ # The GetoptLong class allows you to parse command line options similarly to -# the GNU getopt_long() C library call. Note, however, that GetoptLong is a +# the GNU getopt_long() C library call. Note, however, that GetoptLong is a # pure Ruby implementation. # -# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well +# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well # as single letter options like <tt>-f</tt> # # The empty option <tt>--</tt> (two minus symbols) is used to end option @@ -26,13 +26,13 @@ # # require 'getoptlong' # require 'rdoc/usage' -# +# # opts = GetoptLong.new( # [ '--help', '-h', GetoptLong::NO_ARGUMENT ], # [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ], # [ '--name', GetoptLong::OPTIONAL_ARGUMENT ] # ) -# +# # dir = nil # name = nil # repetitions = 1 @@ -41,16 +41,16 @@ # when '--help' # puts <<-EOF # hello [OPTION] ... DIR -# +# # -h, --help: # show help -# +# # --repeat x, -n x: # repeat x times -# +# # --name [name]: # greet user by name, if name not supplied default is John -# +# # DIR: The directory in which to issue the greeting. # EOF # when '--repeat' @@ -63,12 +63,12 @@ # end # end # end -# +# # if ARGV.length != 1 # puts "Missing dir argument (try --help)" # exit 0 # end -# +# # dir = ARGV.shift # # Dir.chdir(dir) @@ -114,7 +114,7 @@ class GetoptLong # Set up option processing. # # The options to support are passed to new() as an array of arrays. - # Each sub-array contains any number of String option names which carry + # Each sub-array contains any number of String option names which carry # the same meaning, and one of the following flags: # # GetoptLong::NO_ARGUMENT :: Option does not take an argument. @@ -194,23 +194,23 @@ class GetoptLong # the processing of options as follows: # # <b>REQUIRE_ORDER</b> : - # + # # Options are required to occur before non-options. # # Processing of options ends as soon as a word is encountered that has not # been preceded by an appropriate option flag. # # For example, if -a and -b are options which do not take arguments, - # parsing command line arguments of '-a one -b two' would result in - # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being + # parsing command line arguments of '-a one -b two' would result in + # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being # processed as an option/arg pair. # # This is the default ordering, if the environment variable # POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.) # # <b>PERMUTE</b> : - # - # Options can occur anywhere in the command line parsed. This is the + # + # Options can occur anywhere in the command line parsed. This is the # default behavior. # # Every sequence of words which can be interpreted as an option (with or @@ -227,7 +227,7 @@ class GetoptLong # # <b>RETURN_IN_ORDER</b> : # - # All words on the command line are processed as options. Words not + # All words on the command line are processed as options. Words not # preceded by a short or long option flag are passed as arguments # with an option of '' (empty string). # @@ -273,7 +273,7 @@ class GetoptLong # The method is failed if option processing has already started. # if @status != STATUS_YET - raise RuntimeError, + raise RuntimeError, "invoke set_options, but option processing has already started" end @@ -320,7 +320,7 @@ class GetoptLong end # - # Register the option (`i') to the `@canonical_names' and + # Register the option (`i') to the `@canonical_names' and # `@canonical_names' Hashes. # if canonical_name == nil @@ -452,7 +452,7 @@ class GetoptLong return nil end argument = ARGV.shift - elsif @ordering == REQUIRE_ORDER + elsif @ordering == REQUIRE_ORDER if (ARGV[0] !~ /^-./) terminate return nil @@ -589,7 +589,7 @@ class GetoptLong # # The block is called repeatedly with two arguments: # The first is the option name. - # The second is the argument which followed it (if any). + # The second is the argument which followed it (if any). # Example: ('--opt', 'value') # # The option name is always converted to the first (preferred) |