getopt 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca47de7a2b707c120f664cddb09b52ea83437da650968259b2bca08bded4b9d6
4
- data.tar.gz: 0afa07ce4a5c65753fcb9cc9e1b878b1b83cb7cdce590fbe01dda585c19e923f
3
+ metadata.gz: 8fb3a945490a612eaf1e604f83dea2a0e1adecd5b3469c83e214bcb99eacd076
4
+ data.tar.gz: 13521ceb0616ee5e34e6434e6b2c94dc12be959eec7ca210977c1b5ce903c723
5
5
  SHA512:
6
- metadata.gz: c1e31f007d67944148636e8db0b0700fd9c62399ca1b7961af769a4ccc7fa9deed32c49ba9e73daf3df099e647ede6480fe5951ff9a8ea63561c02a40e79fc78
7
- data.tar.gz: f5ed551262c5e84c5b30a7c445174933081866394db9b448ac2ded94a2001597383aa1f0ebbfc699f5b9c16964b6ba2604d0801b8bcb5b566d50e0f755579474
6
+ metadata.gz: 528a9e0c5f0c7aed85fc510e8f823b75b9b40b8f5142a8373474a4f643005ce1ab497f42657802f30dc8b0f002a6154ada4b246a93fa2ee9cc84c197f7621140
7
+ data.tar.gz: 2ff2aaf442063fbb69d5a96eff5e098b2e10d7472922263424ee9fd3d0539916d08201b04635de80b3abec9a8b40ebe24732eb9ef5ddd705c488d4209b198865
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,40 +1,44 @@
1
- == 1.5.1 - 23-Mar-2020
1
+ ## 1.6.0 - 2-Mar-2021
2
+ * Switch from test-unit to rspec, and update the Rakefile and gemspec accordingly.
3
+ * Added a Gemfile.
4
+
5
+ ## 1.5.1 - 23-Mar-2020
2
6
  * Properly add a LICENSE file since the Apache-2.0 license requires it.
3
7
  * Added explicit .rdoc extensions to the README, CHANGES and MANIFEST files,
4
8
  mostly so they look nicer on github.
5
9
 
6
- == 1.5.0 - 25-Jan-2019
10
+ ## 1.5.0 - 25-Jan-2019
7
11
  * Changed license to Apache-2.0.
8
12
 
9
- == 1.4.4 - 24-Mar-2018
13
+ ## 1.4.4 - 24-Mar-2018
10
14
  * Fixed a deprecation warning.
11
15
  * Now requires Ruby 2.2 or later.
12
16
  * Added metadata to the gemspec.
13
17
  * Updated the cert.
14
18
 
15
- == 1.4.3 - 7-Jan-2016
19
+ ## 1.4.3 - 7-Jan-2016
16
20
  * This gem is now signed.
17
21
  * The gem related tasks in the Rakefile now assume Rubygems 2.x.
18
22
  * Added getopt.rb, getopt-std.rb and getopt-long.rb files for convenience.
19
23
 
20
- == 1.4.2 - 12-Oct-2014
24
+ ## 1.4.2 - 12-Oct-2014
21
25
  * Updated Rakefile, README and gemspec.
22
26
  * Minor updates to the test file and examples.
23
27
 
24
- == 1.4.1 - 17-Jul-2011
28
+ ## 1.4.1 - 17-Jul-2011
25
29
  * Now works with Ruby 1.9.x. Thanks go to Shura for the patch.
26
30
  * Refactored the gemspec. Gem building code is now handled by Rake tasks.
27
31
  * Refactored the Rakefile. Added a default task, removed the old install
28
32
  task, and namespaced the gem related tasks.
29
33
 
30
- == 1.4.0 - 5-Sep-2009
34
+ ## 1.4.0 - 5-Sep-2009
31
35
  * Fixed a packaging bug where the libs weren't actually being included! Gah!
32
36
  Thanks go to Steven Hilton for the spot.
33
37
  * Other minor refactorings to the gemspec.
34
38
  * The release number does not reflect any code changes. I simply ran out
35
39
  of numbers. :)
36
40
 
37
- == 1.3.9 - 29-Jul-2009
41
+ ## 1.3.9 - 29-Jul-2009
38
42
  * Now compatible with Ruby 1.9.x.
39
43
  * Gemspec updates, including a license change to Artistic 2.0.
40
44
  * Added individual rake tasks for testing Getopt::Long and Getopt::Std.
@@ -42,7 +46,7 @@
42
46
  * The test-unit library was switched from a standard dependency to a
43
47
  development dependency.
44
48
 
45
- == 1.3.8 - 6-Jan-2008
49
+ ## 1.3.8 - 6-Jan-2008
46
50
  * Fixed RF bug #23477 - Getopt::Std inadvertently raises an error if you
47
51
  pass a letter (without a hyphen) as an argument to a switch that matches
48
52
  that letter, e.g. "-a a" should be legal. Thanks go to an anonymous user
@@ -50,7 +54,7 @@
50
54
  * Added tests for RF bug #23477.
51
55
  * Added Test::Unit 2.x as a prerequisite.
52
56
 
53
- == 1.3.7 - 27-Jul-2008
57
+ ## 1.3.7 - 27-Jul-2008
54
58
  * Fixed a potential infinite hash recursion bug in ARGV processing. This
55
59
  was smoked out as the result of the alternate hash implementations in
56
60
  JRuby and Ruby 1.9.
@@ -58,41 +62,41 @@
58
62
  * Removed the ts_all.rb file, and renamed the other test files. The Rakefile
59
63
  test task was updated accordingly.
60
64
 
61
- == 1.3.6 - 8-Aug-2007
65
+ ## 1.3.6 - 8-Aug-2007
62
66
  * The Getopt::StdError class is now Getopt::Std::Error.
63
67
  * The Getopt::LongError class is now Getopt::Long::Error.
64
68
  * Added some inline rdoc documentation to the source code.
65
69
  * Added a Rakefile with tasks for installation and testing.
66
70
  * Removed the install.rb file - use the 'rake install' task instead.
67
71
 
68
- == 1.3.5 - 5-Jul-2006
72
+ ## 1.3.5 - 5-Jul-2006
69
73
  * Fixed a bug where multiple long switches with the same first character
70
74
  could cause invalid results. Thanks go to Michael Campbell for the spot.
71
75
  * Added documentation to the README file that explains what happens if you
72
76
  specify multiple long switches with the same first character and no short
73
77
  switch alias.
74
78
 
75
- == 1.3.4 - 7-Mar-2006
79
+ ## 1.3.4 - 7-Mar-2006
76
80
  * Fixed Getopt::Long so that it can handle embedded hyphens in the long
77
81
  form, e.g. --foo-bar. Thanks go to Mark Meves for the spot.
78
82
  * Corresponding test suite additions.
79
83
  * Added example to the 'example_long.rb' file that uses long form with
80
84
  embedded hyphens.
81
85
 
82
- == 1.3.3 - 22-Feb-2006
86
+ ## 1.3.3 - 22-Feb-2006
83
87
  * Bug fix for the two argument form of Getopt::Long.getopts.
84
88
  * Corresponding test suite additions.
85
89
 
86
- == 1.3.2 - 13-Feb-2006
90
+ ## 1.3.2 - 13-Feb-2006
87
91
  * Improved error message if an option is passed without a preceding switch.
88
92
  * Minor documentation fixes and clarifications.
89
93
 
90
- == 1.3.1 - 18-Nov-2005
94
+ ## 1.3.1 - 18-Nov-2005
91
95
  * Added support for compressed switches with getopt/long.
92
96
  * More tests.
93
97
  * Fixed a bug in the gemspec.
94
98
 
95
- == 1.3.0 - 4-Nov-2005
99
+ ## 1.3.0 - 4-Nov-2005
96
100
  * Added the Getopt::Long class (long.rb). This is a complete revamp of the
97
101
  old getoptlong package, with ideas tossed in from Perl's Getopt::Long
98
102
  package. See the README and example script for more detail.
@@ -100,14 +104,14 @@
100
104
  * Added lots of documentation to the README file.
101
105
  * Updated the MANIFEST, test suite, etc.
102
106
 
103
- == 1.2.0 - 24-Oct-2005
107
+ ## 1.2.0 - 24-Oct-2005
104
108
  * Altered the way multiple occurrences of the same switch are handled, for
105
109
  those switches that accept arguments.
106
110
 
107
- == 1.1.0 - 7-Oct-2005
111
+ ## 1.1.0 - 7-Oct-2005
108
112
  * Changed parser, added a bit stricter enforcement
109
113
  * Now handles squished arguments properly, e.g. "-ID" as well as "-I -D"
110
114
  * Some test suite changes
111
115
 
112
- == 1.0.0 - 5-Oct-2005
116
+ ## 1.0.0 - 5-Oct-2005
113
117
  * Initial commit
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org' do
2
+ gemspec
3
+ end
@@ -1,7 +1,8 @@
1
- * CHANGES.rdoc
1
+ * CHANGES.md
2
2
  * LICENSE
3
- * MANIFEST.rdoc
4
- * README.rdoc
3
+ * MANIFEST.md
4
+ * README.md
5
+ * Gemfile
5
6
  * Rakefile
6
7
  * getopt.gemspec
7
8
  * certs/djberg96_pub.pem
@@ -1,71 +1,74 @@
1
- = Description
1
+ ## Description
2
+ The getopt Ruby library is a simple command line parsing library. It implements
3
+ a `Getopt::Std` class for basic command line parsing, as well as a `Getopt::Long`
4
+ class for more advanced command line parsing.
2
5
 
3
- Implements a simple Getopt::Std class for command line parsing, as well
4
- as a Getopt::Long class for more advanced command line parsing.
5
-
6
- = Installation
7
-
8
- gem install getopt
6
+ ## Installation
7
+ `gem install getopt`
9
8
 
10
- = Synopsis
11
- == Getopt::Std
12
-
13
- require 'getopt/std'
14
-
15
- # Look for -o with argument, and -I and -D boolean arguments
16
- opt = Getopt::Std.getopts("o:ID")
17
-
18
- if opt["I"]
19
- # Do something if -I passed
20
-
21
- if opt["D"]
22
- # Do something if -D passed
23
-
24
- if opt["o"]
25
- case opt["o"]
26
- # blah, blah, blah
27
- end
9
+ ## Synopsis
10
+ ### Getopt::Std
11
+ ```ruby
12
+ require 'getopt/std'
13
+
14
+ # Look for -o with argument, and -I and -D boolean arguments
15
+ opt = Getopt::Std.getopts("o:ID")
16
+
17
+ if opt["I"]
18
+ # Do something if -I passed
19
+
20
+ if opt["D"]
21
+ # Do something if -D passed
22
+
23
+ if opt["o"]
24
+ case opt["o"]
25
+ # blah, blah, blah
28
26
  end
29
-
30
- == Getopt::Long
31
-
32
- require 'getopt/long'
33
-
34
- opt = Getopt::Long.getopts(
35
- ["--foo", "-f", Getopt::BOOLEAN],
36
- ["--bar", "-b", Getopt::REQUIRED]
37
- )
38
-
39
- # Or, to save your fingers some typing:
40
- #
41
- # require "getopt/long"
42
- # include Getopt
43
- # opt = Long.getopts(
44
- # ["--foo", "-f", BOOLEAN],
45
- # ["--bar", "-b", REQUIRED]
46
- # )
47
-
48
- if opt["foo"]
49
- # Do something if --foo or -f passed
50
-
51
- if opt["b"]
52
- # Do something if --bar or -b passed
53
-
54
- = Class Methods
55
-
56
- Std.getopts(switches)
27
+ end
28
+ ```
29
+
30
+ ### Getopt::Long
31
+ ```ruby
32
+ require 'getopt/long'
33
+
34
+ opt = Getopt::Long.getopts(
35
+ ["--foo", "-f", Getopt::BOOLEAN],
36
+ ["--bar", "-b", Getopt::REQUIRED]
37
+ )
38
+
39
+ # Or, to save your fingers some typing:
40
+ #
41
+ # require "getopt/long"
42
+ # include Getopt
43
+ # opt = Long.getopts(
44
+ # ["--foo", "-f", BOOLEAN],
45
+ # ["--bar", "-b", REQUIRED]
46
+ # )
47
+
48
+ if opt["foo"]
49
+ # Do something if --foo or -f passed
50
+ end
51
+
52
+ if opt["b"]
53
+ # Do something if --bar or -b passed
54
+ end
55
+ ```
56
+
57
+ ## Singleton Methods
58
+ `Std.getopts(switches)`
57
59
 
58
60
  Takes a series of single character switches that can be accepted on the
59
- command line. Those characters followed by a ':' require an argument. The
60
- rest are considered boolean switches. Returns a hash, with the switches
61
- as the key (sans the leading '-'). For boolean switches, the value is
62
- either true or false. Switches that were not passed on the command line
63
- do not appear in the hash.
61
+ command line. Any characters followed by a ":" require an argument. The
62
+ rest are considered boolean switches.
64
63
 
65
- In the event that a switch that accepts an argument appears multiple times
64
+ The method returns a hash, with the switches as the key (minus the leading '-').
65
+ For boolean switches, the value is either true or false. Switches that were
66
+ not passed on the command line do not appear in the hash.
67
+
68
+ In the event that a switch which accepts an argument appears multiple times
66
69
  the value for that key becomes an array of values.
67
70
 
68
- Long.getopts(switches)
71
+ `Long.getopts(switches)`
69
72
 
70
73
  Takes an array of switches beginning with "--" followed by one or more
71
74
  alphanumeric or hyphen characters, or "-" followed by a single character.
@@ -74,12 +77,14 @@ REQUIRED or INCREMENT.
74
77
 
75
78
  The array should be in the form:
76
79
 
77
- # long form, short form (alias), option type
78
- ["--long", "-l", Getopt::OPTION]
80
+ ```
81
+ # long form, short form (alias), option type
82
+ ["--long", "-l", Getopt::OPTION]
83
+ ```
79
84
 
80
- Note that only the long form is required. If the short form is not
85
+ Note that only the long form is required. If the short form is not
81
86
  specified, it will automatically be set to the first letter of the long
82
- switch. If multiple long switches with the same first character are
87
+ switch. If multiple long switches with the same first character are
83
88
  listed without short switches, only the first long switch gets the short
84
89
  switch alias.
85
90
 
@@ -90,34 +95,33 @@ no short switches or argument types).
90
95
 
91
96
  See the 'examples' directory for more examples.
92
97
 
93
- = Getopt::Long argument types
94
-
95
- REQUIRED
98
+ ## Getopt::Long argument types
99
+ `REQUIRED`
96
100
 
97
101
  If the option is specified on the command line, it must be followed by
98
102
  a non-blank argument. This argument cannot be another switch. If this
99
103
  switch appears multiple times, the values are collected into an array.
100
104
 
101
- BOOLEAN
105
+ `BOOLEAN`
102
106
 
103
107
  If the option is specified on the command line, its value is set to true.
104
108
  It must not be followed by a non-blank argument, excluding other switches.
105
109
  Attempting to pass a boolean switch more than once will raise an error.
106
110
 
107
- OPTIONAL
111
+ `OPTIONAL`
108
112
 
109
113
  If the option is specified on the command line, it may or may not accept
110
114
  an argument, excluding other valid switches. If an argument is present,
111
115
  it's value is set to that argument. If an argument is not present, it's
112
116
  value is set to nil.
113
117
 
114
- INCREMENT
118
+ `INCREMENT`
115
119
 
116
120
  If the option is specified on the command line, its value is incremented
117
121
  by one for each appearance on the command line, or set to 1 if it appears
118
122
  only once.
119
123
 
120
- = Future Plans
124
+ ## Future Plans
121
125
 
122
126
  * Add support for negatable options so that you can do "--no-foo", for example.
123
127
 
@@ -127,40 +131,38 @@ only once.
127
131
  * Allow shortcut characters for the option types, e.g. "?" for BOOLEAN, "+"
128
132
  for INCREMENT, etc.
129
133
 
130
- = Known Issues
131
-
132
- == Getopt::Std
134
+ ## Known Issues
133
135
 
136
+ ### Getopt::Std
134
137
  You cannot squish switches that require arguments with the argument itself.
135
- For example, if you do Getopt::Std.getopts("o:ID"), it will not parse
138
+ For example, if you do `Getopt::Std.getopts("o:ID")`, it will not parse
136
139
  "-IDohello" properly. Instead, you must do "-IDo hello". Or, you can just
137
140
  separate the argument, e.g. "-I -D -o hello".
138
141
 
139
- == Getopt::Long
140
-
142
+ ### Getopt::Long
141
143
  If you mix and match compressed switches with separate, optional switches
142
144
  the optional switch will be set to true instead of nil if it separated
143
145
  from the compressed switches.
144
146
 
145
- == Reporting Issues
147
+ ## Reporting Issues
146
148
 
147
149
  If you find any other issues, please log them on the project
148
150
  page at https://github.com/djberg96/getopt.
149
151
 
150
- = Other Stuff
151
-
152
- Neither class attempts to be POSIX compliant in any way, shape or form. And I don't care!
152
+ ## Other Stuff
153
+ Neither class attempts to be POSIX compliant in any way, shape or form.
153
154
 
154
- = Notes From the Author
155
+ And I don't care!
155
156
 
156
- My main gripe with the getoptlong library currently in the standard library
157
+ ## Notes From the Author
158
+ My main gripe with the `getoptlong` library currently in the standard library
157
159
  is that it doesn't return a hash, yet gives you partial hash behavior. This
158
160
  was both confusing and annoying, since the first thing I do (along with
159
161
  everyone else) is collect the results into a hash for later processing.
160
162
 
161
- My main gripe with the optparse library (also in the standard library) is
163
+ My main gripe with the `optparse` library (also in the standard library) is
162
164
  that it treats command line processing like event processing. It's too
163
- complex, when 90% of the time all you want to do is slurp the command line
165
+ complex, when most of the time all you want to do is slurp the command line
164
166
  options into a hash.
165
167
 
166
168
  So, I did something utterly novel with this library. I collected the command
@@ -177,23 +179,19 @@ Getopt::Long module.
177
179
 
178
180
  If you plan to write a full fledged command line application, e.g. you plan
179
181
  on implementing a full help system, gobs of command line options and tons of
180
- switches, consider Jim Freeze's 'commandline' gem.
181
-
182
- = Warranty
182
+ switches, consider Jim Freeze's `commandline` gem.
183
183
 
184
+ ## Warranty
184
185
  This package is provided "as is" and without any express or
185
186
  implied warranties, including, without limitation, the implied
186
187
  warranties of merchantability and fitness for a particular purpose.
187
188
 
188
- = License
189
-
189
+ ## License
190
190
  Apache-2.0
191
191
 
192
- = Copyright
193
-
194
- (C) 2005-2020, Daniel J. Berger
192
+ ## Copyright
193
+ (C) 2005-2021, Daniel J. Berger
195
194
  All Rights Reserved
196
195
 
197
- = Author
198
-
196
+ ## Author
199
197
  Daniel J. Berger
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
 
5
5
  CLEAN.include("**/*.gem", "**/*.rbc")
6
6
 
@@ -10,7 +10,7 @@ namespace :gem do
10
10
  require 'rubygems/package'
11
11
  spec = eval(IO.read('getopt.gemspec'))
12
12
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
- Gem::Package.build(spec, true)
13
+ Gem::Package.build(spec)
14
14
  end
15
15
 
16
16
  desc "Install the getopt gem"
@@ -20,23 +20,18 @@ namespace :gem do
20
20
  end
21
21
  end
22
22
 
23
- Rake::TestTask.new do |t|
24
- t.warning = true
25
- t.verbose = true
26
- end
23
+ namespace :spec do
24
+ RSpec::Core::RakeTask.new(:all) do |t|
25
+ t.pattern = FileList['spec/*_spec.rb']
26
+ end
27
27
 
28
- namespace :test do
29
- Rake::TestTask.new('getopt_long') do |t|
30
- t.test_files = 'test/test_getopt_long.rb'
31
- t.warning = true
32
- t.verbose = true
28
+ RSpec::Core::RakeTask.new(:getopt_long) do |t|
29
+ t.pattern = FileList['spec/*long_spec.rb']
33
30
  end
34
31
 
35
- Rake::TestTask.new('getopt_std') do |t|
36
- t.test_files = 'test/test_getopt_std.rb'
37
- t.warning = true
38
- t.verbose = true
32
+ RSpec::Core::RakeTask.new(:getopt_std) do |t|
33
+ t.pattern = FileList['spec/*std_spec.rb']
39
34
  end
40
35
  end
41
36
 
42
- task :default => :test
37
+ task :default => 'spec:all'