optparse 0.4.0 → 0.5.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: 393ddfd5f19439c98112418ff879314c8570d9955e4a26a148b6d3bd94354cda
4
- data.tar.gz: 270b3538983dfd6920cae9b2fcda5d7dcb5304157ae1e323a0d56daf33a6dd60
3
+ metadata.gz: a5a9ef5004e5838005ad874fc163ebd1e6266d3319d08be502a8fb2d6b6b48a2
4
+ data.tar.gz: 94fb689cea59f667e4bc4788a6713a50cd829b4e552097994e7b9833f5f35432
5
5
  SHA512:
6
- metadata.gz: 80e82b866fccf4b8598d3b495941629255ddfa907a8686a092d9ab5135d145d1c0a83d9d3d42ededcf1d33e21bc5ea6bfbee79f40085140e29a4ac54e6b96a1d
7
- data.tar.gz: 998881fc6568b9725d7874145111cdee53e2366050a63f0e5908395f183d080eda16bf6740e8d83f90fe60064cf85fb424c24cd70e4589b344ee9dc3b997d283
6
+ metadata.gz: 5d0d3a7e51d10a3636e337dfdbe6562ae32e5e4ee18ef61926460f964900f5341f75ae3dd308901e2c1bdf8d5e1c1bd4434d8fe1e2fc77b366bf68690fa9ec85
7
+ data.tar.gz: e494246dfe20878a07d79d3489918b9383a2ade4076023a4fd1ec5f973c2f8111066b85fa8e49b69303ff8ff7301adc4ad5c7d3cccde5650ef93afa9b7819030
data/.document ADDED
@@ -0,0 +1,7 @@
1
+ COPYING
2
+ ChangeLog
3
+ README.md
4
+ doc/
5
+ lib/
6
+ logs/
7
+ misc/
data/.rdoc_options ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ page_dir: doc
3
+ main_page: README.md
4
+ title: Documentation for OptionParser
data/ChangeLog CHANGED
@@ -1,163 +1,275 @@
1
1
  -*- coding: utf-8 -*-
2
2
 
3
- commit acbf6e3e12de4d116f7215b64432f204d293da97
4
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
5
- AuthorDate: 2023-11-07 10:40:38 +0900
6
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
7
- CommitDate: 2023-11-07 10:40:38 +0900
3
+ commit 979bd76281d28044b3def3eadba233a87e62415a
4
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
5
+ AuthorDate: 2024-04-15 18:42:47 +0900
6
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
7
+ CommitDate: 2024-04-15 18:42:47 +0900
8
8
 
9
- Bump up 0.4.0
9
+ [DOC] Split fetching commits and building package
10
10
 
11
- commit 38848ce4b31977d4a892c2a5573b304c77208283
12
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
13
- AuthorDate: 2023-10-05 16:17:40 +0900
14
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
15
- CommitDate: 2023-10-05 16:26:53 +0900
11
+ commit ca883bd3a1ac13957774fcb93e8bccd80b74c9d1
12
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
13
+ AuthorDate: 2024-04-15 18:21:31 +0900
14
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
15
+ CommitDate: 2024-04-15 18:21:31 +0900
16
16
 
17
- Use test-unit-ruby-core gem
17
+ [DOC] git on Github Actions is old
18
18
 
19
- commit a291ef5c26445d423bf0223b0cb64340df18f0cb
20
- Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
21
- AuthorDate: 2023-09-11 03:20:53 +0000
22
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
23
- CommitDate: 2023-09-11 14:02:17 +0900
19
+ It does not support `--unshallow-exclude` option.
24
20
 
25
- Bump actions/checkout from 3 to 4
21
+ commit 7f79bc820ff0e04a05204ec63c5fc3e9c85e14ad
22
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
23
+ AuthorDate: 2024-04-15 18:08:57 +0900
24
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
25
+ CommitDate: 2024-04-15 18:08:57 +0900
26
26
 
27
- Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
28
- - [Release notes](https://github.com/actions/checkout/releases)
29
- - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
30
- - [Commits](https://github.com/actions/checkout/compare/v3...v4)
27
+ [DOC] Fix error when no tag found
31
28
 
32
- ---
33
- updated-dependencies:
34
- - dependency-name: actions/checkout
35
- dependency-type: direct:production
36
- update-type: version-update:semver-major
37
- ...
29
+ commit add085df63d79d878a8901c42f2cfc3eec56307f
30
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
31
+ AuthorDate: 2024-04-15 15:57:09 +0900
32
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
33
+ CommitDate: 2024-04-15 15:58:54 +0900
38
34
 
39
- Signed-off-by: dependabot[bot] <support@github.com>
35
+ Fetch upto the previous tag for changelogs
40
36
 
41
- commit 2940dbb65a7df013995934a93e6906109adda766
42
- Author: BurdetteLamar <burdettelamar@yahoo.com>
43
- AuthorDate: 2023-07-30 16:35:00 +0100
44
- Commit: BurdetteLamar <burdettelamar@yahoo.com>
45
- CommitDate: 2023-07-30 16:35:00 +0100
37
+ commit 436a5c516b67f8aec900f2361567c6fc163ade05
38
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
39
+ AuthorDate: 2024-04-15 15:08:19 +0900
40
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
41
+ CommitDate: 2024-04-15 15:08:19 +0900
46
42
 
47
- [DOC] Corrections to tutorial
43
+ [DOC] Make timestamps in a ISO 8601-like format
48
44
 
49
- commit e8bee0be8f52f5a3e08d0db09a13798701670391
45
+ commit 3a2dcd72d1fdabf63218cd13c8c7953cb3c28f6b
50
46
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
51
- AuthorDate: 2023-07-30 11:24:59 +0900
47
+ AuthorDate: 2024-04-15 14:55:14 +0900
52
48
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
53
- CommitDate: 2023-07-30 11:24:59 +0900
49
+ CommitDate: 2024-04-15 14:55:14 +0900
50
+
51
+ [DOC] Make ChangeLog non-empty
54
52
 
55
- [DOC] Mark up constant and method names as code
53
+ When the latest version is tagged at the head, there is no commit
54
+ between the tag and the head. Make from the previous tag.
56
55
 
57
- commit 3cde2178d3d1bd1c7bf9c7e2af930e89e0bad6e5
56
+ commit b7382c02f1092f2c0ef0f4096d3b8428e2adf3fa
58
57
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
59
- AuthorDate: 2023-07-12 01:07:11 +0900
58
+ AuthorDate: 2024-04-15 14:49:59 +0900
60
59
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
61
- CommitDate: 2023-07-12 01:07:37 +0900
60
+ CommitDate: 2024-04-15 14:49:59 +0900
62
61
 
63
- Upload according to build results
62
+ [DOC] Exclude CI-skipped commits from changelogs
64
63
 
65
- commit fb91d97c109269aee4fb0f7ecc1b3826dad118d8
66
- Author: Jeremy Evans <code@jeremyevans.net>
67
- AuthorDate: 2023-04-04 13:58:59 -0700
68
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
69
- CommitDate: 2023-04-05 08:43:45 +0900
64
+ commit b49cb996afdd68e4eb373ba602c95b52c963d160
65
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
66
+ AuthorDate: 2024-04-15 14:24:19 +0900
67
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
68
+ CommitDate: 2024-04-15 14:24:19 +0900
70
69
 
71
- Document requires needed for Date/DateTime/Time/URI/Shellwords support
70
+ [DOC] Package files for RDoc
72
71
 
73
- Fixes [Bug #19566]
72
+ commit f5018a8b1ce82f7ac7458d00d099a454c3c03ea1
73
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
74
+ AuthorDate: 2024-04-15 14:05:43 +0900
75
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
76
+ CommitDate: 2024-04-15 14:05:43 +0900
74
77
 
75
- commit 5bf4fa8a72a00d0891106af21655800db1d2ceff
76
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
77
- AuthorDate: 2023-03-24 13:01:25 +0900
78
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
79
- CommitDate: 2023-03-24 13:38:04 +0900
78
+ bump up to 0.5.0
80
79
 
81
- Update test libraries from https://github.com/ruby/ruby/commit/b4e438d8aabaf4bba2b27f374c787543fae07c58
80
+ commit ece4bb2673c7fa9f53133ba91bbffd423ebadc90
81
+ Author: Koichi Sasada <ko1@atdot.net>
82
+ AuthorDate: 2024-03-27 07:29:38 +0900
83
+ Commit: Koichi Sasada <ko1@atdot.net>
84
+ CommitDate: 2024-04-15 12:08:07 +0900
82
85
 
83
- commit b67cc2407e6f9b5b4c9bc0751e21fa4969da0ceb
84
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
85
- AuthorDate: 2023-02-18 16:37:54 +0900
86
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
87
- CommitDate: 2023-02-18 16:46:18 +0900
86
+ show warning for unused block
88
87
 
89
- Skip build and upload package with Windows
88
+ With verbopse mode (-w), the interpreter shows a warning if
89
+ a block is passed to a method which does not use the given block.
90
90
 
91
- commit fd6621a23da2e8d3d1a3ab75003dbfeb0e42e2ab
92
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
93
- AuthorDate: 2023-02-18 16:31:55 +0900
94
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
95
- CommitDate: 2023-02-18 16:46:18 +0900
91
+ Warning on:
96
92
 
97
- Exclude JRuby from Windows
93
+ * the invoked method is not written in C
94
+ * the invoked method is not `initialize`
95
+ * not invoked with `super`
96
+ * the first time on the call-site with the invoked method
97
+ (`obj.foo{}` will be warned once if `foo` is same method)
98
98
 
99
- commit 426726fa170ab5a1ddba4f2ef04ae6864ed2a625
100
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
101
- AuthorDate: 2023-02-18 16:25:39 +0900
102
- Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
103
- CommitDate: 2023-02-18 16:46:18 +0900
99
+ [Feature #15554]
100
+
101
+ `Primitive.attr! :use_block` is introduced to declare that primitive
102
+ functions (written in C) will use passed block.
103
+
104
+ For minitest, test needs some tweak, so use
105
+ https://github.com/minitest/minitest/commit/ea9caafc0754b1d6236a490d59e624b53209734a
106
+ for `test-bundled-gems`.
107
+
108
+ ruby/ruby@9180e33ca3a5886fec3f9e0a2f48072b55914e65
109
+
110
+ commit 77dccce37cb9fd1b8fbc52160d4103d1c4579669
111
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
112
+ AuthorDate: 2024-03-01 01:24:05 +0900
113
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
114
+ CommitDate: 2024-03-01 01:24:05 +0900
115
+
116
+ Invoke pager for `--help`
117
+
118
+ commit 59b9fd7ddca3e795c235aa397655b51de2e4c949
119
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
120
+ AuthorDate: 2024-02-23 21:49:57 +0900
121
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
122
+ CommitDate: 2024-02-23 21:49:57 +0900
104
123
 
105
- Try with Windows
124
+ [DOC] About return value of OptionParser#new
106
125
 
107
- commit 45fade52f519f656f62eb601899e3e96d3f69fca
108
- Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
109
- AuthorDate: 2023-02-18 16:25:25 +0900
126
+ commit 07e83673a8e99b5b7985608a69f713abde3344f6
127
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
128
+ AuthorDate: 2024-02-21 13:42:11 +0900
129
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
130
+ CommitDate: 2024-02-23 21:13:51 +0900
131
+
132
+ Add `exact:` keyword argument
133
+
134
+ commit bbec64d0c7f198429b62468b64b27692efa18dc2
135
+ Author: Yusuke Endoh <mame@ruby-lang.org>
136
+ AuthorDate: 2024-01-19 16:03:38 +0900
110
137
  Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
111
- CommitDate: 2023-02-18 16:46:18 +0900
138
+ CommitDate: 2024-02-16 10:47:36 +0900
139
+
140
+ Do not include a backtick in error messages and backtraces
112
141
 
113
- Use ruby/actions/.github/workflows/ruby_versions.yml@master
142
+ [Feature #16495]
114
143
 
115
- commit 366a6a6b569037420013e83ada92012d0c6a2f76
116
- Author: Keishi Tanaka <k-tanaka@ruby-dev.jp>
117
- AuthorDate: 2023-01-21 14:09:00 +0900
118
- Commit: GitHub <noreply@github.com>
119
- CommitDate: 2023-01-21 14:09:00 +0900
144
+ commit 451dea51a0e5d062fb4cb75b1073a2c2b8609bef
145
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
146
+ AuthorDate: 2024-02-12 01:30:58 +0900
147
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
148
+ CommitDate: 2024-02-12 01:30:58 +0900
149
+
150
+ [DOC] Add description of OptionParser#define_by_keywords
120
151
 
121
- Migrate set-output to $GITHUB_OUTPUT (#50)
152
+ commit 33956ce93f56320978cedfcebb8b6cf18bf96c53
153
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
154
+ AuthorDate: 2024-02-12 01:07:05 +0900
155
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
156
+ CommitDate: 2024-02-12 01:07:05 +0900
122
157
 
123
- https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
158
+ [DOC] Add missing documents
124
159
 
125
- commit 3e63d878f895a299a6ddeee5f8c615b69edf401c
126
- Author: Junichi Ito <jit@sonicgarden.jp>
127
- AuthorDate: 2022-11-29 08:07:47 +0900
160
+ commit 78afdab30751e1b7cf80bb57d6696b10879f90fe
161
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
162
+ AuthorDate: 2024-02-10 22:56:32 +0900
128
163
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
129
- CommitDate: 2022-12-22 19:58:43 +0900
164
+ CommitDate: 2024-02-10 22:56:32 +0900
130
165
 
131
- Add symbolize_names to getopts
166
+ Search exactly when `require_exact`
132
167
 
133
- commit 73661899ad17e1061c7fc0f88cc4ac4e66a3c9a9
168
+ To work with options defined as `--[no]-something`.
169
+
170
+ Fix https://bugs.ruby-lang.org/issues/20252
171
+ Fix #60
172
+
173
+ commit 213cb03b5978ddacfbcc8f71ec837d9a6fd4c56d
134
174
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
135
- AuthorDate: 2022-12-22 19:57:30 +0900
175
+ AuthorDate: 2024-02-09 19:03:20 +0900
136
176
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
137
- CommitDate: 2022-12-22 19:57:30 +0900
177
+ CommitDate: 2024-02-09 19:03:20 +0900
178
+
179
+ Adjust arguments for lambda-callbacks
138
180
 
139
- bump up to 0.4.0.pre.1
181
+ Rake uses [lambda] as callbacks.
182
+ Calling it without omitted argument raises an `ArgumentError`.
140
183
 
141
- commit 697ea7bf8e343704e735fb2d1f7787d96b843469
184
+ lambda: https://github.com/ruby/rake/blob/master/lib/rake/application.rb#L543
185
+
186
+ commit 9d53e74aa4421e0c4e2a805a0074ece5aae3773f
142
187
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
143
- AuthorDate: 2022-12-22 19:55:51 +0900
188
+ AuthorDate: 2024-02-09 12:59:43 +0900
144
189
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
145
- CommitDate: 2022-12-22 19:55:51 +0900
190
+ CommitDate: 2024-02-09 12:59:43 +0900
191
+
192
+ Respect default values in block parameters
146
193
 
147
- Add .rdoc_options
194
+ Fix #55
148
195
 
149
- commit ab0022bd23d77e515390cbb2c165f7647400be46
196
+ commit 4e346ad337f400dbff855798e859f17455698c2a
197
+ Author: fatkodima <fatkodima123@gmail.com>
198
+ AuthorDate: 2023-10-14 21:52:01 +0300
199
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
200
+ CommitDate: 2024-02-09 12:31:08 +0900
201
+
202
+ Fix `require_exact` to work with options defined as `--[no]-something`
203
+
204
+ commit b14c2c644d18cce226e49ccde8a23b5b991ea8cf
150
205
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
151
- AuthorDate: 2021-09-29 11:47:47 +0900
206
+ AuthorDate: 2024-02-09 12:17:31 +0900
207
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
208
+ CommitDate: 2024-02-09 12:17:31 +0900
209
+
210
+ Escape backslashes
211
+
212
+ commit 434e92fc62ff9571124335a2eedff56df83dae48
213
+ Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
214
+ AuthorDate: 2023-12-18 03:43:27 +0000
152
215
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
153
- CommitDate: 2022-12-22 19:53:20 +0900
216
+ CommitDate: 2024-02-09 12:14:30 +0900
154
217
 
155
- Cron test
218
+ Bump actions/upload-artifact from 3 to 4
156
219
 
157
- commit 33663e2c50eb8496b81750976b3480c14783470d
220
+ Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
221
+ - [Release notes](https://github.com/actions/upload-artifact/releases)
222
+ - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)
223
+
224
+ ---
225
+ updated-dependencies:
226
+ - dependency-name: actions/upload-artifact
227
+ dependency-type: direct:production
228
+ update-type: version-update:semver-major
229
+ ...
230
+
231
+ Signed-off-by: dependabot[bot] <support@github.com>
232
+
233
+ commit 48385d3eaf37cd10140274453eeadc4496581fc2
234
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
235
+ AuthorDate: 2024-02-09 12:01:44 +0900
236
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
237
+ CommitDate: 2024-02-09 12:06:40 +0900
238
+
239
+ Create codeql.yml
240
+
241
+ commit 294c6e1ed4b170a8a34ab95c84453829c170223c
242
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
243
+ AuthorDate: 2023-12-25 15:08:05 +0900
244
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
245
+ CommitDate: 2023-12-25 15:08:05 +0900
246
+
247
+ Build packages only on the latest release
248
+
249
+ commit 324ff21f042769444cde41949fc0321f6c6ccf63
250
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
251
+ AuthorDate: 2023-12-18 12:45:44 +0900
252
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
253
+ CommitDate: 2023-12-18 12:45:44 +0900
254
+
255
+ [DOC] Add missing documents
256
+
257
+ commit 667ab35f593f81b7850009385453d20ca8023bba
158
258
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
159
- AuthorDate: 2022-12-22 19:48:22 +0900
259
+ AuthorDate: 2023-12-18 12:24:46 +0900
160
260
  Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
161
- CommitDate: 2022-12-22 19:50:16 +0900
261
+ CommitDate: 2023-12-18 12:24:46 +0900
262
+
263
+ [DOC] Add missing secition
264
+
265
+ Fixes #51
266
+
267
+ commit 1c895efc39ed2290c185dcb80523fee381dfe74e
268
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
269
+ AuthorDate: 2023-12-18 12:15:31 +0900
270
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
271
+ CommitDate: 2023-12-18 12:15:31 +0900
272
+
273
+ [DOC] Fix tutorial link
162
274
 
163
- Add `helper.bump`
275
+ Fixes #51
@@ -0,0 +1 @@
1
+ *.rdoc
@@ -31,7 +31,7 @@ Contents:
31
31
  - {Long Names with Optional Arguments}[#label-Long+Names+with+Optional+Arguments]
32
32
  - {Long Names with Negation}[#label-Long+Names+with+Negation]
33
33
  - {Mixed Names}[#label-Mixed+Names]
34
- - {Argument Styles}[#label-Argument+Styles]
34
+ - {Argument Strings}[#label-Argument+Strings]
35
35
  - {Argument Values}[#label-Argument+Values]
36
36
  - {Explicit Argument Values}[#label-Explicit+Argument+Values]
37
37
  - {Explicit Values in Array}[#label-Explicit+Values+in+Array]
@@ -0,0 +1,9 @@
1
+ require 'optparse'
2
+ parser = OptionParser.new
3
+ parser.on('-x', '--xxx=VALUE', %w[ABC def], 'Argument abbreviations') do |value|
4
+ p ['--xxx', value]
5
+ end
6
+ parser.on('-y', '--yyy=VALUE', {"abc"=>"XYZ", def: "FOO"}, 'Argument abbreviations') do |value|
7
+ p ['--yyy', value]
8
+ end
9
+ parser.parse!
@@ -351,6 +351,29 @@ Executions:
351
351
 
352
352
  Omitting an optional argument does not raise an error.
353
353
 
354
+ ==== Argument Abbreviations
355
+
356
+ Specify an argument list as an Array or a Hash.
357
+
358
+ :include: ruby/argument_abbreviation.rb
359
+
360
+ When an argument is abbreviated, the expanded argument yielded.
361
+
362
+ Executions:
363
+
364
+ $ ruby argument_abbreviation.rb --help
365
+ Usage: argument_abbreviation [options]
366
+ Usage: argument_abbreviation [options]
367
+ -x, --xxx=VALUE Argument abbreviations
368
+ -y, --yyy=VALUE Argument abbreviations
369
+ $ ruby argument_abbreviation.rb --xxx A
370
+ ["--xxx", "ABC"]
371
+ $ ruby argument_abbreviation.rb --xxx c
372
+ argument_abbreviation.rb:9:in `<main>': invalid argument: --xxx c (OptionParser::InvalidArgument)
373
+ $ ruby argument_abbreviation.rb --yyy a --yyy d
374
+ ["--yyy", "XYZ"]
375
+ ["--yyy", "FOO"]
376
+
354
377
  === Argument Values
355
378
 
356
379
  Permissible argument values may be restricted
data/lib/optparse/ac.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: false
2
2
  require_relative '../optparse'
3
3
 
4
+ #
5
+ # autoconf-like options.
6
+ #
4
7
  class OptionParser::AC < OptionParser
8
+ # :stopdoc:
5
9
  private
6
10
 
7
11
  def _check_ac_args(name, block)
@@ -14,6 +18,7 @@ class OptionParser::AC < OptionParser
14
18
  end
15
19
 
16
20
  ARG_CONV = proc {|val| val.nil? ? true : val}
21
+ private_constant :ARG_CONV
17
22
 
18
23
  def _ac_arg_enable(prefix, name, help_string, block)
19
24
  _check_ac_args(name, block)
@@ -29,16 +34,27 @@ class OptionParser::AC < OptionParser
29
34
  enable
30
35
  end
31
36
 
37
+ # :startdoc:
38
+
32
39
  public
33
40
 
41
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
42
+ #
43
+ # Appears as <tt>--enable-<i>name</i></tt> in help message.
34
44
  def ac_arg_enable(name, help_string, &block)
35
45
  _ac_arg_enable("enable", name, help_string, block)
36
46
  end
37
47
 
48
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
49
+ #
50
+ # Appears as <tt>--disable-<i>name</i></tt> in help message.
38
51
  def ac_arg_disable(name, help_string, &block)
39
52
  _ac_arg_enable("disable", name, help_string, block)
40
53
  end
41
54
 
55
+ # Define <tt>--with</tt> / <tt>--without</tt> style option
56
+ #
57
+ # Appears as <tt>--with-<i>name</i></tt> in help message.
42
58
  def ac_arg_with(name, help_string, &block)
43
59
  _check_ac_args(name, block)
44
60
 
@@ -7,12 +7,17 @@ class OptionParser
7
7
  #
8
8
  # :include: ../../doc/optparse/creates_option.rdoc
9
9
  #
10
- def define_by_keywords(options, meth, **opts)
11
- meth.parameters.each do |type, name|
10
+ # Defines options which set in to _options_ for keyword parameters
11
+ # of _method_.
12
+ #
13
+ # Parameters for each keywords are given as elements of _params_.
14
+ #
15
+ def define_by_keywords(options, method, **params)
16
+ method.parameters.each do |type, name|
12
17
  case type
13
18
  when :key, :keyreq
14
19
  op, cl = *(type == :key ? %w"[ ]" : ["", ""])
15
- define("--#{name}=#{op}#{name.upcase}#{cl}", *opts[name]) do |o|
20
+ define("--#{name}=#{op}#{name.upcase}#{cl}", *params[name]) do |o|
16
21
  options[name] = o
17
22
  end
18
23
  end
@@ -2,6 +2,11 @@
2
2
  # OptionParser internal utility
3
3
 
4
4
  class << OptionParser
5
+ #
6
+ # Shows version string in packages if Version is defined.
7
+ #
8
+ # +pkgs+:: package list
9
+ #
5
10
  def show_version(*pkgs)
6
11
  progname = ARGV.options.program_name
7
12
  result = false
@@ -47,6 +52,8 @@ class << OptionParser
47
52
  result
48
53
  end
49
54
 
55
+ # :stopdoc:
56
+
50
57
  def each_const(path, base = ::Object)
51
58
  path.split(/::|\//).inject(base) do |klass, name|
52
59
  raise NameError, path unless Module === klass
@@ -68,4 +75,6 @@ class << OptionParser
68
75
  end
69
76
  end
70
77
  end
78
+
79
+ # :startdoc:
71
80
  end
data/lib/optparse.rb CHANGED
@@ -8,7 +8,6 @@
8
8
  # See OptionParser for documentation.
9
9
  #
10
10
 
11
-
12
11
  #--
13
12
  # == Developer Documentation (not for RDoc output)
14
13
  #
@@ -425,7 +424,8 @@
425
424
  # If you have any questions, file a ticket at http://bugs.ruby-lang.org.
426
425
  #
427
426
  class OptionParser
428
- OptionParser::Version = "0.4.0"
427
+ # The version string
428
+ OptionParser::Version = "0.5.0"
429
429
 
430
430
  # :stopdoc:
431
431
  NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
@@ -438,6 +438,8 @@ class OptionParser
438
438
  # and resolved against a list of acceptable values.
439
439
  #
440
440
  module Completion
441
+ # :nodoc:
442
+
441
443
  def self.regexp(key, icase)
442
444
  Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
443
445
  end
@@ -459,7 +461,7 @@ class OptionParser
459
461
  candidates
460
462
  end
461
463
 
462
- def candidate(key, icase = false, pat = nil)
464
+ def candidate(key, icase = false, pat = nil, &_)
463
465
  Completion.candidate(key, icase, pat, &method(:each))
464
466
  end
465
467
 
@@ -510,6 +512,8 @@ class OptionParser
510
512
  # RequiredArgument, etc.
511
513
  #
512
514
  class Switch
515
+ # :nodoc:
516
+
513
517
  attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
514
518
 
515
519
  #
@@ -697,6 +701,11 @@ class OptionParser
697
701
  q.object_group(self) {pretty_print_contents(q)}
698
702
  end
699
703
 
704
+ def omitted_argument(val) # :nodoc:
705
+ val.pop if val.size == 3 and val.last.nil?
706
+ val
707
+ end
708
+
700
709
  #
701
710
  # Switch that takes no arguments.
702
711
  #
@@ -710,10 +719,10 @@ class OptionParser
710
719
  conv_arg(arg)
711
720
  end
712
721
 
713
- def self.incompatible_argument_styles(*)
722
+ def self.incompatible_argument_styles(*) # :nodoc:
714
723
  end
715
724
 
716
- def self.pattern
725
+ def self.pattern # :nodoc:
717
726
  Object
718
727
  end
719
728
 
@@ -730,7 +739,7 @@ class OptionParser
730
739
  #
731
740
  # Raises an exception if argument is not present.
732
741
  #
733
- def parse(arg, argv)
742
+ def parse(arg, argv, &_)
734
743
  unless arg
735
744
  raise MissingArgument if argv.empty?
736
745
  arg = argv.shift
@@ -755,7 +764,7 @@ class OptionParser
755
764
  if arg
756
765
  conv_arg(*parse_arg(arg, &error))
757
766
  else
758
- conv_arg(arg)
767
+ omitted_argument conv_arg(arg)
759
768
  end
760
769
  end
761
770
 
@@ -774,13 +783,14 @@ class OptionParser
774
783
  #
775
784
  def parse(arg, argv, &error)
776
785
  if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
777
- return nil, block, nil
786
+ return nil, block
778
787
  end
779
788
  opt = (val = parse_arg(val, &error))[1]
780
789
  val = conv_arg(*val)
781
790
  if opt and !arg
782
791
  argv.shift
783
792
  else
793
+ omitted_argument val
784
794
  val[0] = nil
785
795
  end
786
796
  val
@@ -798,6 +808,8 @@ class OptionParser
798
808
  # matching pattern and converter pair. Also provides summary feature.
799
809
  #
800
810
  class List
811
+ # :nodoc:
812
+
801
813
  # Map from acceptable argument types to pattern and converter pairs.
802
814
  attr_reader :atype
803
815
 
@@ -837,7 +849,7 @@ class OptionParser
837
849
  def accept(t, pat = /.*/m, &block)
838
850
  if pat
839
851
  pat.respond_to?(:match) or
840
- raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
852
+ raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
841
853
  else
842
854
  pat = t if t.respond_to?(:match)
843
855
  end
@@ -1033,11 +1045,31 @@ XXX
1033
1045
  to << "#compdef #{name}\n"
1034
1046
  to << COMPSYS_HEADER
1035
1047
  visit(:compsys, {}, {}) {|o, d|
1036
- to << %Q[ "#{o}[#{d.gsub(/[\"\[\]]/, '\\\\\&')}]" \\\n]
1048
+ to << %Q[ "#{o}[#{d.gsub(/[\\\"\[\]]/, '\\\\\&')}]" \\\n]
1037
1049
  }
1038
1050
  to << " '*:file:_files' && return 0\n"
1039
1051
  end
1040
1052
 
1053
+ def help_exit
1054
+ if STDOUT.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?})
1055
+ less = ENV["LESS"]
1056
+ args = [{"LESS" => "#{!less || less.empty? ? '-' : less}Fe"}, pager, "w"]
1057
+ print = proc do |f|
1058
+ f.puts help
1059
+ rescue Errno::EPIPE
1060
+ # pager terminated
1061
+ end
1062
+ if Process.respond_to?(:fork) and false
1063
+ IO.popen("-") {|f| f ? Process.exec(*args, in: f) : print.call(STDOUT)}
1064
+ # unreachable
1065
+ end
1066
+ IO.popen(*args, &print)
1067
+ else
1068
+ puts help
1069
+ end
1070
+ exit
1071
+ end
1072
+
1041
1073
  #
1042
1074
  # Default options for ARGV, which never appear in option summary.
1043
1075
  #
@@ -1049,8 +1081,7 @@ XXX
1049
1081
  #
1050
1082
  Officious['help'] = proc do |parser|
1051
1083
  Switch::NoArgument.new do |arg|
1052
- puts parser.help
1053
- exit
1084
+ parser.help_exit
1054
1085
  end
1055
1086
  end
1056
1087
 
@@ -1129,6 +1160,10 @@ XXX
1129
1160
  default.to_i + 1
1130
1161
  end
1131
1162
  end
1163
+
1164
+ #
1165
+ # See self.inc
1166
+ #
1132
1167
  def inc(*args)
1133
1168
  self.class.inc(*args)
1134
1169
  end
@@ -1167,11 +1202,19 @@ XXX
1167
1202
  def terminate(arg = nil)
1168
1203
  self.class.terminate(arg)
1169
1204
  end
1205
+ #
1206
+ # See #terminate.
1207
+ #
1170
1208
  def self.terminate(arg = nil)
1171
1209
  throw :terminate, arg
1172
1210
  end
1173
1211
 
1174
1212
  @stack = [DefaultList]
1213
+ #
1214
+ # Returns the global top option list.
1215
+ #
1216
+ # Do not use directly.
1217
+ #
1175
1218
  def self.top() DefaultList end
1176
1219
 
1177
1220
  #
@@ -1192,9 +1235,9 @@ XXX
1192
1235
  #
1193
1236
  # Directs to reject specified class argument.
1194
1237
  #
1195
- # +t+:: Argument class specifier, any object including Class.
1238
+ # +type+:: Argument class specifier, any object including Class.
1196
1239
  #
1197
- # reject(t)
1240
+ # reject(type)
1198
1241
  #
1199
1242
  def reject(*args, &blk) top.reject(*args, &blk) end
1200
1243
  #
@@ -1284,10 +1327,24 @@ XXX
1284
1327
  end
1285
1328
  end
1286
1329
 
1330
+ #
1331
+ # Shows warning message with the program name
1332
+ #
1333
+ # +mesg+:: Message, defaulted to +$!+.
1334
+ #
1335
+ # See Kernel#warn.
1336
+ #
1287
1337
  def warn(mesg = $!)
1288
1338
  super("#{program_name}: #{mesg}")
1289
1339
  end
1290
1340
 
1341
+ #
1342
+ # Shows message with the program name then aborts.
1343
+ #
1344
+ # +mesg+:: Message, defaulted to +$!+.
1345
+ #
1346
+ # See Kernel#abort.
1347
+ #
1291
1348
  def abort(mesg = $!)
1292
1349
  super("#{program_name}: #{mesg}")
1293
1350
  end
@@ -1309,6 +1366,9 @@ XXX
1309
1366
  #
1310
1367
  # Pushes a new List.
1311
1368
  #
1369
+ # If a block is given, yields +self+ and returns the result of the
1370
+ # block, otherwise returns +self+.
1371
+ #
1312
1372
  def new
1313
1373
  @stack.push(List.new)
1314
1374
  if block_given?
@@ -1532,6 +1592,12 @@ XXX
1532
1592
  nolong
1533
1593
  end
1534
1594
 
1595
+ # ----
1596
+ # Option definition phase methods
1597
+ #
1598
+ # These methods are used to define options, or to construct an
1599
+ # OptionParser instance in other words.
1600
+
1535
1601
  # :call-seq:
1536
1602
  # define(*params, &block)
1537
1603
  #
@@ -1607,6 +1673,13 @@ XXX
1607
1673
  top.append(string, nil, nil)
1608
1674
  end
1609
1675
 
1676
+ # ----
1677
+ # Arguments parse phase methods
1678
+ #
1679
+ # These methods parse +argv+, convert, and store the results by
1680
+ # calling handlers. As these methods do not modify +self+, +self+
1681
+ # can be frozen.
1682
+
1610
1683
  #
1611
1684
  # Parses command line arguments +argv+ in order. When a block is given,
1612
1685
  # each non-option argument is yielded. When optional +into+ keyword
@@ -1616,21 +1689,21 @@ XXX
1616
1689
  #
1617
1690
  # Returns the rest of +argv+ left unparsed.
1618
1691
  #
1619
- def order(*argv, into: nil, &nonopt)
1692
+ def order(*argv, **keywords, &nonopt)
1620
1693
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1621
- order!(argv, into: into, &nonopt)
1694
+ order!(argv, **keywords, &nonopt)
1622
1695
  end
1623
1696
 
1624
1697
  #
1625
1698
  # Same as #order, but removes switches destructively.
1626
1699
  # Non-option arguments remain in +argv+.
1627
1700
  #
1628
- def order!(argv = default_argv, into: nil, &nonopt)
1701
+ def order!(argv = default_argv, into: nil, **keywords, &nonopt)
1629
1702
  setter = ->(name, val) {into[name.to_sym] = val} if into
1630
- parse_in_order(argv, setter, &nonopt)
1703
+ parse_in_order(argv, setter, **keywords, &nonopt)
1631
1704
  end
1632
1705
 
1633
- def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
1706
+ def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
1634
1707
  opt, arg, val, rest = nil
1635
1708
  nonopt ||= proc {|a| throw :terminate, a}
1636
1709
  argv.unshift(arg) if arg = catch(:terminate) {
@@ -1641,19 +1714,24 @@ XXX
1641
1714
  opt, rest = $1, $2
1642
1715
  opt.tr!('_', '-')
1643
1716
  begin
1644
- sw, = complete(:long, opt, true)
1645
- if require_exact && !sw.long.include?(arg)
1646
- throw :terminate, arg unless raise_unknown
1647
- raise InvalidOption, arg
1717
+ if exact
1718
+ sw, = search(:long, opt)
1719
+ else
1720
+ sw, = complete(:long, opt, true)
1648
1721
  end
1649
1722
  rescue ParseError
1650
1723
  throw :terminate, arg unless raise_unknown
1651
1724
  raise $!.set_option(arg, true)
1725
+ else
1726
+ unless sw
1727
+ throw :terminate, arg unless raise_unknown
1728
+ raise InvalidOption, arg
1729
+ end
1652
1730
  end
1653
1731
  begin
1654
- opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
1655
- val = cb.call(val) if cb
1656
- setter.call(sw.switch_name, val) if setter
1732
+ opt, cb, *val = sw.parse(rest, argv) {|*exc| raise(*exc)}
1733
+ val = callback!(cb, 1, *val) if cb
1734
+ callback!(setter, 2, sw.switch_name, *val) if setter
1657
1735
  rescue ParseError
1658
1736
  raise $!.set_option(arg, rest)
1659
1737
  end
@@ -1671,7 +1749,7 @@ XXX
1671
1749
  val = arg.delete_prefix('-')
1672
1750
  has_arg = true
1673
1751
  rescue InvalidOption
1674
- raise if require_exact
1752
+ raise if exact
1675
1753
  # if no short options match, try completion with long
1676
1754
  # options.
1677
1755
  sw, = complete(:long, opt)
@@ -1683,7 +1761,7 @@ XXX
1683
1761
  raise $!.set_option(arg, true)
1684
1762
  end
1685
1763
  begin
1686
- opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
1764
+ opt, cb, *val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
1687
1765
  rescue ParseError
1688
1766
  raise $!.set_option(arg, arg.length > 2)
1689
1767
  else
@@ -1691,8 +1769,8 @@ XXX
1691
1769
  end
1692
1770
  begin
1693
1771
  argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-')
1694
- val = cb.call(val) if cb
1695
- setter.call(sw.switch_name, val) if setter
1772
+ val = callback!(cb, 1, *val) if cb
1773
+ callback!(setter, 2, sw.switch_name, *val) if setter
1696
1774
  rescue ParseError
1697
1775
  raise $!.set_option(arg, arg.length > 2)
1698
1776
  end
@@ -1718,6 +1796,17 @@ XXX
1718
1796
  end
1719
1797
  private :parse_in_order
1720
1798
 
1799
+ # Calls callback with _val_.
1800
+ def callback!(cb, max_arity, *args) # :nodoc:
1801
+ if (size = args.size) < max_arity and cb.to_proc.lambda?
1802
+ (arity = cb.arity) < 0 and arity = (1-arity)
1803
+ arity = max_arity if arity > max_arity
1804
+ args[arity - 1] = nil if arity > size
1805
+ end
1806
+ cb.call(*args)
1807
+ end
1808
+ private :callback!
1809
+
1721
1810
  #
1722
1811
  # Parses command line arguments +argv+ in permutation mode and returns
1723
1812
  # list of non-option arguments. When optional +into+ keyword
@@ -1725,18 +1814,18 @@ XXX
1725
1814
  # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
1726
1815
  # similar object).
1727
1816
  #
1728
- def permute(*argv, into: nil)
1817
+ def permute(*argv, **keywords)
1729
1818
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1730
- permute!(argv, into: into)
1819
+ permute!(argv, **keywords)
1731
1820
  end
1732
1821
 
1733
1822
  #
1734
1823
  # Same as #permute, but removes switches destructively.
1735
1824
  # Non-option arguments remain in +argv+.
1736
1825
  #
1737
- def permute!(argv = default_argv, into: nil)
1826
+ def permute!(argv = default_argv, **keywords)
1738
1827
  nonopts = []
1739
- order!(argv, into: into, &nonopts.method(:<<))
1828
+ order!(argv, **keywords, &nonopts.method(:<<))
1740
1829
  argv[0, 0] = nonopts
1741
1830
  argv
1742
1831
  end
@@ -1748,20 +1837,20 @@ XXX
1748
1837
  # values are stored there via <code>[]=</code> method (so it can be Hash,
1749
1838
  # or OpenStruct, or other similar object).
1750
1839
  #
1751
- def parse(*argv, into: nil)
1840
+ def parse(*argv, **keywords)
1752
1841
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1753
- parse!(argv, into: into)
1842
+ parse!(argv, **keywords)
1754
1843
  end
1755
1844
 
1756
1845
  #
1757
1846
  # Same as #parse, but removes switches destructively.
1758
1847
  # Non-option arguments remain in +argv+.
1759
1848
  #
1760
- def parse!(argv = default_argv, into: nil)
1849
+ def parse!(argv = default_argv, **keywords)
1761
1850
  if ENV.include?('POSIXLY_CORRECT')
1762
- order!(argv, into: into)
1851
+ order!(argv, **keywords)
1763
1852
  else
1764
- permute!(argv, into: into)
1853
+ permute!(argv, **keywords)
1765
1854
  end
1766
1855
  end
1767
1856
 
@@ -1784,7 +1873,7 @@ XXX
1784
1873
  # # params[:bar] = "x" # --bar x
1785
1874
  # # params[:zot] = "z" # --zot Z
1786
1875
  #
1787
- def getopts(*args, symbolize_names: false)
1876
+ def getopts(*args, symbolize_names: false, **keywords)
1788
1877
  argv = Array === args.first ? args.shift : default_argv
1789
1878
  single_options, *long_options = *args
1790
1879
 
@@ -1812,7 +1901,7 @@ XXX
1812
1901
  end
1813
1902
  end
1814
1903
 
1815
- parse_in_order(argv, result.method(:[]=))
1904
+ parse_in_order(argv, result.method(:[]=), **keywords)
1816
1905
  symbolize_names ? result.transform_keys(&:to_sym) : result
1817
1906
  end
1818
1907
 
@@ -1881,6 +1970,9 @@ XXX
1881
1970
  DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
1882
1971
  end
1883
1972
 
1973
+ #
1974
+ # Return candidates for +word+.
1975
+ #
1884
1976
  def candidate(word)
1885
1977
  list = []
1886
1978
  case word
@@ -1922,10 +2014,10 @@ XXX
1922
2014
  # The optional +into+ keyword argument works exactly like that accepted in
1923
2015
  # method #parse.
1924
2016
  #
1925
- def load(filename = nil, into: nil)
2017
+ def load(filename = nil, **keywords)
1926
2018
  unless filename
1927
2019
  basename = File.basename($0, '.*')
1928
- return true if load(File.expand_path(basename, '~/.options'), into: into) rescue nil
2020
+ return true if load(File.expand_path(basename, '~/.options'), **keywords) rescue nil
1929
2021
  basename << ".options"
1930
2022
  return [
1931
2023
  # XDG
@@ -1937,11 +2029,11 @@ XXX
1937
2029
  '~/config/settings',
1938
2030
  ].any? {|dir|
1939
2031
  next if !dir or dir.empty?
1940
- load(File.expand_path(basename, dir), into: into) rescue nil
2032
+ load(File.expand_path(basename, dir), **keywords) rescue nil
1941
2033
  }
1942
2034
  end
1943
2035
  begin
1944
- parse(*File.readlines(filename, chomp: true), into: into)
2036
+ parse(*File.readlines(filename, chomp: true), **keywords)
1945
2037
  true
1946
2038
  rescue Errno::ENOENT, Errno::ENOTDIR
1947
2039
  false
@@ -1954,10 +2046,10 @@ XXX
1954
2046
  #
1955
2047
  # +env+ defaults to the basename of the program.
1956
2048
  #
1957
- def environment(env = File.basename($0, '.*'))
2049
+ def environment(env = File.basename($0, '.*'), **keywords)
1958
2050
  env = ENV[env] || ENV[env.upcase] or return
1959
2051
  require 'shellwords'
1960
- parse(*Shellwords.shellwords(env))
2052
+ parse(*Shellwords.shellwords(env), **keywords)
1961
2053
  end
1962
2054
 
1963
2055
  #
@@ -2123,6 +2215,7 @@ XXX
2123
2215
  # Reason which caused the error.
2124
2216
  Reason = 'parse error'
2125
2217
 
2218
+ # :nodoc:
2126
2219
  def initialize(*args, additional: nil)
2127
2220
  @additional = additional
2128
2221
  @arg0, = args
@@ -2273,19 +2366,19 @@ XXX
2273
2366
  # Parses +self+ destructively in order and returns +self+ containing the
2274
2367
  # rest arguments left unparsed.
2275
2368
  #
2276
- def order!(&blk) options.order!(self, &blk) end
2369
+ def order!(**keywords, &blk) options.order!(self, **keywords, &blk) end
2277
2370
 
2278
2371
  #
2279
2372
  # Parses +self+ destructively in permutation mode and returns +self+
2280
2373
  # containing the rest arguments left unparsed.
2281
2374
  #
2282
- def permute!() options.permute!(self) end
2375
+ def permute!(**keywords) options.permute!(self, **keywords) end
2283
2376
 
2284
2377
  #
2285
2378
  # Parses +self+ destructively and returns +self+ containing the
2286
2379
  # rest arguments left unparsed.
2287
2380
  #
2288
- def parse!() options.parse!(self) end
2381
+ def parse!(**keywords) options.parse!(self, **keywords) end
2289
2382
 
2290
2383
  #
2291
2384
  # Substitution of getopts is possible as follows. Also see
@@ -2298,8 +2391,8 @@ XXX
2298
2391
  # rescue OptionParser::ParseError
2299
2392
  # end
2300
2393
  #
2301
- def getopts(*args, symbolize_names: false)
2302
- options.getopts(self, *args, symbolize_names: symbolize_names)
2394
+ def getopts(*args, symbolize_names: false, **keywords)
2395
+ options.getopts(self, *args, symbolize_names: symbolize_names, **keywords)
2303
2396
  end
2304
2397
 
2305
2398
  #
@@ -2309,7 +2402,8 @@ XXX
2309
2402
  super
2310
2403
  obj.instance_eval {@optparse = nil}
2311
2404
  end
2312
- def initialize(*args)
2405
+
2406
+ def initialize(*args) # :nodoc:
2313
2407
  super
2314
2408
  @optparse = nil
2315
2409
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: OptionParser is a class for command-line option analysis.
14
14
  email:
@@ -17,12 +17,16 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".document"
21
+ - ".rdoc_options"
20
22
  - COPYING
21
23
  - ChangeLog
22
24
  - README.md
25
+ - doc/optparse/.document
23
26
  - doc/optparse/argument_converters.rdoc
24
27
  - doc/optparse/creates_option.rdoc
25
28
  - doc/optparse/option_params.rdoc
29
+ - doc/optparse/ruby/argument_abbreviation.rb
26
30
  - doc/optparse/ruby/argument_keywords.rb
27
31
  - doc/optparse/ruby/argument_strings.rb
28
32
  - doc/optparse/ruby/argv.rb
@@ -115,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
119
  - !ruby/object:Gem::Version
116
120
  version: '0'
117
121
  requirements: []
118
- rubygems_version: 3.5.0.dev
122
+ rubygems_version: 3.5.3
119
123
  signing_key:
120
124
  specification_version: 4
121
125
  summary: OptionParser is a class for command-line option analysis.