optparse 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +277 -0
- data/doc/optparse/argument_converters.rdoc +380 -0
- data/doc/optparse/creates_option.rdoc +7 -0
- data/doc/optparse/option_params.rdoc +509 -0
- data/doc/optparse/ruby/argument_keywords.rb +6 -0
- data/doc/optparse/ruby/argument_strings.rb +6 -0
- data/doc/optparse/ruby/argv.rb +2 -0
- data/doc/optparse/ruby/array.rb +6 -0
- data/doc/optparse/ruby/basic.rb +17 -0
- data/doc/optparse/ruby/block.rb +9 -0
- data/doc/optparse/ruby/collected_options.rb +8 -0
- data/doc/optparse/ruby/custom_converter.rb +9 -0
- data/doc/optparse/ruby/date.rb +6 -0
- data/doc/optparse/ruby/datetime.rb +6 -0
- data/doc/optparse/ruby/decimal_integer.rb +7 -0
- data/doc/optparse/ruby/decimal_numeric.rb +7 -0
- data/doc/optparse/ruby/default_values.rb +8 -0
- data/doc/optparse/ruby/descriptions.rb +15 -0
- data/doc/optparse/ruby/explicit_array_values.rb +9 -0
- data/doc/optparse/ruby/explicit_hash_values.rb +9 -0
- data/doc/optparse/ruby/false_class.rb +6 -0
- data/doc/optparse/ruby/float.rb +6 -0
- data/doc/optparse/ruby/help.rb +18 -0
- data/doc/optparse/ruby/help_banner.rb +7 -0
- data/doc/optparse/ruby/help_format.rb +25 -0
- data/doc/optparse/ruby/help_program_name.rb +7 -0
- data/doc/optparse/ruby/integer.rb +6 -0
- data/doc/optparse/ruby/long_names.rb +9 -0
- data/doc/optparse/ruby/long_optional.rb +6 -0
- data/doc/optparse/ruby/long_required.rb +6 -0
- data/doc/optparse/ruby/long_simple.rb +9 -0
- data/doc/optparse/ruby/long_with_negation.rb +6 -0
- data/doc/optparse/ruby/match_converter.rb +9 -0
- data/doc/optparse/ruby/matched_values.rb +6 -0
- data/doc/optparse/ruby/method.rb +11 -0
- data/doc/optparse/ruby/missing_options.rb +12 -0
- data/doc/optparse/ruby/mixed_names.rb +12 -0
- data/doc/optparse/ruby/name_abbrev.rb +9 -0
- data/doc/optparse/ruby/no_abbreviation.rb +10 -0
- data/doc/optparse/ruby/numeric.rb +6 -0
- data/doc/optparse/ruby/object.rb +6 -0
- data/doc/optparse/ruby/octal_integer.rb +7 -0
- data/doc/optparse/ruby/optional_argument.rb +9 -0
- data/doc/optparse/ruby/parse.rb +13 -0
- data/doc/optparse/ruby/parse_bang.rb +13 -0
- data/doc/optparse/ruby/proc.rb +13 -0
- data/doc/optparse/ruby/regexp.rb +6 -0
- data/doc/optparse/ruby/required_argument.rb +9 -0
- data/doc/optparse/ruby/shellwords.rb +6 -0
- data/doc/optparse/ruby/short_names.rb +9 -0
- data/doc/optparse/ruby/short_optional.rb +6 -0
- data/doc/optparse/ruby/short_range.rb +6 -0
- data/doc/optparse/ruby/short_required.rb +6 -0
- data/doc/optparse/ruby/short_simple.rb +9 -0
- data/doc/optparse/ruby/string.rb +6 -0
- data/doc/optparse/ruby/terminator.rb +6 -0
- data/doc/optparse/ruby/time.rb +6 -0
- data/doc/optparse/ruby/true_class.rb +6 -0
- data/doc/optparse/ruby/uri.rb +6 -0
- data/doc/optparse/tutorial.rdoc +835 -0
- data/lib/optparse/ac.rb +1 -1
- data/lib/optparse/date.rb +1 -1
- data/lib/optparse/kwargs.rb +3 -1
- data/lib/optparse/shellwords.rb +1 -1
- data/lib/optparse/time.rb +1 -1
- data/lib/optparse/uri.rb +1 -1
- data/lib/optparse.rb +124 -83
- metadata +67 -9
- data/Rakefile +0 -10
- data/optparse.gemspec +0 -33
- data/rakelib/changelogs.rake +0 -34
- data/rakelib/epoch.rake +0 -5
- data/rakelib/version.rake +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 418e5857a7b44f43280185c3b47044dfeeae912cdfbb1732e1d449959d2f7ea6
|
4
|
+
data.tar.gz: 7bc504678e83873db67b7a70cbf70a9795e6d5c8910ad7829ecc0f161eb09e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5145d4416caf4eb5a64cf415548d56ae7b533089d29b83bd16876fdbde1c644f4b260e1aa3a68010d92107e065f9197c2e0e8691997d80261c5542bbc95ff6ef
|
7
|
+
data.tar.gz: 37cb54b326baa9239ed1366ff2ad465352b8de03a32360f2a4d49e9214a1d6bb01916ebff354787ec378b7d7deb50b2444a1e45eac215fa335b21156ba594818
|
data/ChangeLog
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
-*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
commit c80dfb1ebd9e92142de4a0719f7fb91d753c35e5
|
4
|
+
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
5
|
+
AuthorDate: 2022-12-05 16:17:01 +0900
|
6
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
7
|
+
CommitDate: 2022-12-05 16:17:01 +0900
|
8
|
+
|
9
|
+
Bump version to 0.3.0
|
10
|
+
|
11
|
+
commit fee86ef7a443e602e951ac67143a890a22e8aa3a
|
12
|
+
Author: Yusuke Endoh <mame@ruby-lang.org>
|
13
|
+
AuthorDate: 2022-11-29 01:14:47 +0900
|
14
|
+
Commit: Yusuke Endoh <mame@ruby-lang.org>
|
15
|
+
CommitDate: 2022-11-29 01:14:47 +0900
|
16
|
+
|
17
|
+
Fix the test failure i ruby/ruby
|
18
|
+
|
19
|
+
```
|
20
|
+
$ make test-all TESTS=test/optparse/
|
21
|
+
...
|
22
|
+
|
23
|
+
[148/178] TestOptionParserDidYouMean#test_raise_unknown = 0.00 s
|
24
|
+
1) Failure:
|
25
|
+
TestOptionParserDidYouMean#test_raise_unknown [/home/mame/work/ruby/test/optparse/test_optparse.rb:106]:
|
26
|
+
<["--bar"]> expected but was
|
27
|
+
<[]>.
|
28
|
+
```
|
29
|
+
|
30
|
+
In the old test/unit (bundled in ruby/ruby), when a test class inherits from
|
31
|
+
another test class, the child class runs all the tests defined in the parent
|
32
|
+
class.
|
33
|
+
However, it looks like the new test/unit does not do so. This is because the
|
34
|
+
test failure does not occur in ruby/optparse.
|
35
|
+
|
36
|
+
As a tentative solution, this changes the option names in TestOptionParser to
|
37
|
+
avoid the name conflict with TestOptionParserDidYouMean.
|
38
|
+
|
39
|
+
commit 12529653cd35ed38cb0a00d22ec0fe6e0907ce89
|
40
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
41
|
+
AuthorDate: 2022-10-30 00:36:19 +0900
|
42
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
43
|
+
CommitDate: 2022-11-28 23:23:54 +0900
|
44
|
+
|
45
|
+
Add `raise_unknown` flag (#38)
|
46
|
+
|
47
|
+
commit ab5073e4d8928814a1e667bb93164d6998bf2558
|
48
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
49
|
+
AuthorDate: 2022-11-21 18:28:33 +0900
|
50
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
51
|
+
CommitDate: 2022-11-21 18:30:01 +0900
|
52
|
+
|
53
|
+
Use class methods of `File` over `IO`
|
54
|
+
|
55
|
+
commit 51f7e060ee6e2ccab6b052e7fb14532bc3485ce2
|
56
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
57
|
+
AuthorDate: 2022-10-29 22:25:42 +0900
|
58
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
59
|
+
CommitDate: 2022-10-29 22:46:59 +0900
|
60
|
+
|
61
|
+
Add tests for `load(into:)`
|
62
|
+
|
63
|
+
commit 2ea626fcff72b68b5ae6e1381c28f5db94de7e94
|
64
|
+
Author: Whyme Lyu <5longluna@gmail.com>
|
65
|
+
AuthorDate: 2022-10-29 21:46:23 +0800
|
66
|
+
Commit: GitHub <noreply@github.com>
|
67
|
+
CommitDate: 2022-10-29 22:46:23 +0900
|
68
|
+
|
69
|
+
#load() into hash (#42)
|
70
|
+
|
71
|
+
OptionParser#load learns .load(into: Hash)
|
72
|
+
|
73
|
+
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
74
|
+
|
75
|
+
commit fb34a1d3a36aa33a5d2a02d511fbd705887505b0
|
76
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
77
|
+
AuthorDate: 2022-10-29 22:23:14 +0900
|
78
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
79
|
+
CommitDate: 2022-10-29 22:40:11 +0900
|
80
|
+
|
81
|
+
Add tests for `OptionParser#load`
|
82
|
+
|
83
|
+
commit 078638ee6da875680ebcfd06efa50bb573fd1af2
|
84
|
+
Author: Maciek Rząsa <maciejrzasa@gmail.com>
|
85
|
+
AuthorDate: 2022-10-08 12:30:12 +0200
|
86
|
+
Commit: GitHub <noreply@github.com>
|
87
|
+
CommitDate: 2022-10-08 19:30:12 +0900
|
88
|
+
|
89
|
+
Don't treat empty string as an option description
|
90
|
+
|
91
|
+
commit 3bcca8a81574aaef19a6ba09f91fc1e318aadfa4
|
92
|
+
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
93
|
+
AuthorDate: 2022-06-17 18:35:47 +0900
|
94
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
95
|
+
CommitDate: 2022-06-17 18:41:16 +0900
|
96
|
+
|
97
|
+
Update Ruby versions on GHA with ci_versions/all.json
|
98
|
+
|
99
|
+
commit f2b8318631d3d265131a0b281ee730025eda9027
|
100
|
+
Author: konsolebox <konsolebox@gmail.com>
|
101
|
+
AuthorDate: 2022-06-09 19:43:24 +0800
|
102
|
+
Commit: GitHub <noreply@github.com>
|
103
|
+
CommitDate: 2022-06-09 20:43:24 +0900
|
104
|
+
|
105
|
+
Also accept '-' as an optional argument (#35)
|
106
|
+
|
107
|
+
commit e70e689deddb6c1d72e2073a5c4723b3fdfff68c
|
108
|
+
Author: ydah <13041216+ydah@users.noreply.github.com>
|
109
|
+
AuthorDate: 2022-05-21 06:24:41 +0900
|
110
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
111
|
+
CommitDate: 2022-05-21 08:47:36 +0900
|
112
|
+
|
113
|
+
Fix typo in documentation
|
114
|
+
|
115
|
+
- "hypnen" -> "hyphen"
|
116
|
+
- "hadler" -> "handler"
|
117
|
+
|
118
|
+
commit 4b47d9c24b3b143bc661c3ef5d0de9f71882b4ce
|
119
|
+
Author: Jeremy Evans <code@jeremyevans.net>
|
120
|
+
AuthorDate: 2022-04-22 13:01:43 -0700
|
121
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
122
|
+
CommitDate: 2022-05-02 20:12:12 +0900
|
123
|
+
|
124
|
+
Avoid defining the same test class in multiple files
|
125
|
+
|
126
|
+
Should fix issues with parallel testing sometimes not running all
|
127
|
+
tests.
|
128
|
+
|
129
|
+
This should be viewed skipping whitespace changes.
|
130
|
+
|
131
|
+
Fixes [Bug #18731]
|
132
|
+
|
133
|
+
commit 2bea3b38c354c3a49b5705f9f560eef522b4b1e2
|
134
|
+
Author: Peter Zhu <peter@peterzhu.ca>
|
135
|
+
AuthorDate: 2022-04-14 11:15:57 -0400
|
136
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
137
|
+
CommitDate: 2022-04-15 14:21:13 +0900
|
138
|
+
|
139
|
+
Fix broken links in docs
|
140
|
+
|
141
|
+
commit 3653d5b909d876d3322546a4c2157ea5a94df1b9
|
142
|
+
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
143
|
+
AuthorDate: 2022-04-11 03:21:22 +0000
|
144
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
145
|
+
CommitDate: 2022-04-11 12:39:39 +0900
|
146
|
+
|
147
|
+
Bump actions/upload-artifact from 2 to 3
|
148
|
+
|
149
|
+
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
|
150
|
+
- [Release notes](https://github.com/actions/upload-artifact/releases)
|
151
|
+
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)
|
152
|
+
|
153
|
+
---
|
154
|
+
updated-dependencies:
|
155
|
+
- dependency-name: actions/upload-artifact
|
156
|
+
dependency-type: direct:production
|
157
|
+
update-type: version-update:semver-major
|
158
|
+
...
|
159
|
+
|
160
|
+
Signed-off-by: dependabot[bot] <support@github.com>
|
161
|
+
|
162
|
+
commit a3f0ec21b19bd26111f1025fd8434e55beef309d
|
163
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
164
|
+
AuthorDate: 2022-04-04 15:05:15 +0900
|
165
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
166
|
+
CommitDate: 2022-04-04 15:05:15 +0900
|
167
|
+
|
168
|
+
Define `inspect` and `pretty_inspect`
|
169
|
+
|
170
|
+
commit 482a42668e7228485b3274cfb0523af87ab44e56
|
171
|
+
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
172
|
+
AuthorDate: 2022-03-25 16:56:25 +0900
|
173
|
+
Commit: GitHub <noreply@github.com>
|
174
|
+
CommitDate: 2022-03-25 16:56:25 +0900
|
175
|
+
|
176
|
+
Bump actions/checkout from 2 to 3 (#31)
|
177
|
+
|
178
|
+
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
|
179
|
+
- [Release notes](https://github.com/actions/checkout/releases)
|
180
|
+
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
|
181
|
+
- [Commits](https://github.com/actions/checkout/compare/v2...v3)
|
182
|
+
|
183
|
+
---
|
184
|
+
updated-dependencies:
|
185
|
+
- dependency-name: actions/checkout
|
186
|
+
dependency-type: direct:production
|
187
|
+
update-type: version-update:semver-major
|
188
|
+
...
|
189
|
+
|
190
|
+
Signed-off-by: dependabot[bot] <support@github.com>
|
191
|
+
|
192
|
+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
193
|
+
|
194
|
+
commit 5bc8b13b8806bac75f8aa0adeaa75a6631b992ec
|
195
|
+
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
196
|
+
AuthorDate: 2022-03-25 16:49:09 +0900
|
197
|
+
Commit: GitHub <noreply@github.com>
|
198
|
+
CommitDate: 2022-03-25 16:49:09 +0900
|
199
|
+
|
200
|
+
Added dependabot (#30)
|
201
|
+
|
202
|
+
commit 9e29d86c12819dc383e042cc0059224299a8fcd8
|
203
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
204
|
+
AuthorDate: 2022-01-12 20:58:54 +0900
|
205
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
206
|
+
CommitDate: 2022-01-12 20:58:54 +0900
|
207
|
+
|
208
|
+
Fix for ruby 3.0 or earlier
|
209
|
+
|
210
|
+
commit 0ac99576964657f7f44dadcca4c2546594076f88
|
211
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
212
|
+
AuthorDate: 2022-01-12 19:37:33 +0900
|
213
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
214
|
+
CommitDate: 2022-01-12 19:37:33 +0900
|
215
|
+
|
216
|
+
DidYouMean::PlainFormatter is deprecated
|
217
|
+
|
218
|
+
commit dab72c543db6c0c0f89a470006ae71390adf0c50
|
219
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
220
|
+
AuthorDate: 2022-01-12 18:22:11 +0900
|
221
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
222
|
+
CommitDate: 2022-01-12 18:22:11 +0900
|
223
|
+
|
224
|
+
Fix links to the page directory files
|
225
|
+
|
226
|
+
https://bugs.ruby-lang.org/issues/18468
|
227
|
+
|
228
|
+
commit d182cd60b58eb6bc537f23b0309cde187309056b
|
229
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
230
|
+
AuthorDate: 2022-01-12 18:17:22 +0900
|
231
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
232
|
+
CommitDate: 2022-01-12 18:19:40 +0900
|
233
|
+
|
234
|
+
Add rdoc options
|
235
|
+
|
236
|
+
Specify the main page and the page directory. Also in Rakefile,
|
237
|
+
extract and use the same options from the gemspec file.
|
238
|
+
|
239
|
+
commit ed283559d492e917f1c28b0ece9ea9c3e1327016
|
240
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
241
|
+
AuthorDate: 2022-01-12 18:16:30 +0900
|
242
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
243
|
+
CommitDate: 2022-01-12 18:19:39 +0900
|
244
|
+
|
245
|
+
Add .document files
|
246
|
+
|
247
|
+
commit e4f26821283dbf7d7dba8973e332641cff3f119f
|
248
|
+
Author: David Rodríguez <deivid.rodriguez@riseup.net>
|
249
|
+
AuthorDate: 2022-01-04 08:32:45 +0100
|
250
|
+
Commit: GitHub <noreply@github.com>
|
251
|
+
CommitDate: 2022-01-04 16:32:45 +0900
|
252
|
+
|
253
|
+
Use `require_relative` for internal requires (#28)
|
254
|
+
|
255
|
+
commit faf8e5c8fba85ae2dda8d9d882de4c7016b31ec5
|
256
|
+
Author: Takashi Kokubun <takashikkbn@gmail.com>
|
257
|
+
AuthorDate: 2021-12-14 20:49:32 -0800
|
258
|
+
Commit: GitHub <noreply@github.com>
|
259
|
+
CommitDate: 2021-12-14 20:49:32 -0800
|
260
|
+
|
261
|
+
s/RubyVM::JIT/RubyVM::MJIT/g (#29)
|
262
|
+
|
263
|
+
commit 61df7522f80a04ce40fc7dea655d4b016f224c83
|
264
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
265
|
+
AuthorDate: 2021-11-03 19:52:14 +0900
|
266
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
267
|
+
CommitDate: 2021-11-03 19:52:14 +0900
|
268
|
+
|
269
|
+
Remove the test for deprecated DidYouMean::VerboseFormatter
|
270
|
+
|
271
|
+
commit 0aa18752cfcc2e9bd47afe57348ddc0fc966c981
|
272
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
273
|
+
AuthorDate: 2021-11-03 18:34:13 +0900
|
274
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
275
|
+
CommitDate: 2021-11-03 18:34:13 +0900
|
276
|
+
|
277
|
+
Fix typo [ci skip]
|
@@ -0,0 +1,380 @@
|
|
1
|
+
== Argument Converters
|
2
|
+
|
3
|
+
An option can specify that its argument is to be converted
|
4
|
+
from the default \String to an instance of another class.
|
5
|
+
|
6
|
+
=== Contents
|
7
|
+
|
8
|
+
- {Built-In Argument Converters}[#label-Built-In+Argument+Converters]
|
9
|
+
- {Date}[#label-Date]
|
10
|
+
- {DateTime}[#label-DateTime]
|
11
|
+
- {Time}[#label-Time]
|
12
|
+
- {URI}[#label-URI]
|
13
|
+
- {Shellwords}[#label-Shellwords]
|
14
|
+
- {Integer}[#label-Integer]
|
15
|
+
- {Float}[#label-Float]
|
16
|
+
- {Numeric}[#label-Numeric]
|
17
|
+
- {DecimalInteger}[#label-DecimalInteger]
|
18
|
+
- {OctalInteger}[#label-OctalInteger]
|
19
|
+
- {DecimalNumeric}[#label-DecimalNumeric]
|
20
|
+
- {TrueClass}[#label-TrueClass]
|
21
|
+
- {FalseClass}[#label-FalseClass]
|
22
|
+
- {Object}[#label-Object]
|
23
|
+
- {String}[#label-String]
|
24
|
+
- {Array}[#label-Array]
|
25
|
+
- {Regexp}[#label-Regexp]
|
26
|
+
- {Custom Argument Converters}[#label-Custom+Argument+Converters]
|
27
|
+
|
28
|
+
=== Built-In Argument Converters
|
29
|
+
|
30
|
+
\OptionParser has a number of built-in argument converters,
|
31
|
+
which are demonstrated below.
|
32
|
+
|
33
|
+
==== \Date
|
34
|
+
|
35
|
+
File +date.rb+
|
36
|
+
defines an option whose argument is to be converted to a \Date object.
|
37
|
+
The argument is converted by method Date#parse.
|
38
|
+
|
39
|
+
:include: ruby/date.rb
|
40
|
+
|
41
|
+
Executions:
|
42
|
+
|
43
|
+
$ ruby date.rb --date 2001-02-03
|
44
|
+
[#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
|
45
|
+
$ ruby date.rb --date 20010203
|
46
|
+
[#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
|
47
|
+
$ ruby date.rb --date "3rd Feb 2001"
|
48
|
+
[#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
|
49
|
+
|
50
|
+
==== \DateTime
|
51
|
+
|
52
|
+
File +datetime.rb+
|
53
|
+
defines an option whose argument is to be converted to a \DateTime object.
|
54
|
+
The argument is converted by method DateTime#parse.
|
55
|
+
|
56
|
+
:include: ruby/datetime.rb
|
57
|
+
|
58
|
+
Executions:
|
59
|
+
|
60
|
+
$ ruby datetime.rb --datetime 2001-02-03T04:05:06+07:00
|
61
|
+
[#<DateTime: 2001-02-03T04:05:06+07:00 ((2451943j,75906s,0n),+25200s,2299161j)>, DateTime]
|
62
|
+
$ ruby datetime.rb --datetime 20010203T040506+0700
|
63
|
+
[#<DateTime: 2001-02-03T04:05:06+07:00 ((2451943j,75906s,0n),+25200s,2299161j)>, DateTime]
|
64
|
+
$ ruby datetime.rb --datetime "3rd Feb 2001 04:05:06 PM"
|
65
|
+
[#<DateTime: 2001-02-03T16:05:06+00:00 ((2451944j,57906s,0n),+0s,2299161j)>, DateTime]
|
66
|
+
|
67
|
+
==== \Time
|
68
|
+
|
69
|
+
File +time.rb+
|
70
|
+
defines an option whose argument is to be converted to a \Time object.
|
71
|
+
The argument is converted by method Time#httpdate or Time#parse.
|
72
|
+
|
73
|
+
:include: ruby/time.rb
|
74
|
+
|
75
|
+
Executions:
|
76
|
+
|
77
|
+
$ ruby time.rb --time "Thu, 06 Oct 2011 02:26:12 GMT"
|
78
|
+
[2011-10-06 02:26:12 UTC, Time]
|
79
|
+
$ ruby time.rb --time 2010-10-31
|
80
|
+
[2010-10-31 00:00:00 -0500, Time]
|
81
|
+
|
82
|
+
==== \URI
|
83
|
+
|
84
|
+
File +uri.rb+
|
85
|
+
defines an option whose argument is to be converted to a \URI object.
|
86
|
+
The argument is converted by method URI#parse.
|
87
|
+
|
88
|
+
:include: ruby/uri.rb
|
89
|
+
|
90
|
+
Executions:
|
91
|
+
|
92
|
+
$ ruby uri.rb --uri https://github.com
|
93
|
+
[#<URI::HTTPS https://github.com>, URI::HTTPS]
|
94
|
+
$ ruby uri.rb --uri http://github.com
|
95
|
+
[#<URI::HTTP http://github.com>, URI::HTTP]
|
96
|
+
$ ruby uri.rb --uri file://~/var
|
97
|
+
[#<URI::File file://~/var>, URI::File]
|
98
|
+
|
99
|
+
==== \Shellwords
|
100
|
+
|
101
|
+
File +shellwords.rb+
|
102
|
+
defines an option whose argument is to be converted to an \Array object by method
|
103
|
+
Shellwords#shellwords.
|
104
|
+
|
105
|
+
:include: ruby/shellwords.rb
|
106
|
+
|
107
|
+
Executions:
|
108
|
+
|
109
|
+
$ ruby shellwords.rb --shellwords "ruby my_prog.rb | less"
|
110
|
+
[["ruby", "my_prog.rb", "|", "less"], Array]
|
111
|
+
$ ruby shellwords.rb --shellwords "here are 'two words'"
|
112
|
+
[["here", "are", "two words"], Array]
|
113
|
+
|
114
|
+
==== \Integer
|
115
|
+
|
116
|
+
File +integer.rb+
|
117
|
+
defines an option whose argument is to be converted to an \Integer object.
|
118
|
+
The argument is converted by method Kernel#Integer.
|
119
|
+
|
120
|
+
:include: ruby/integer.rb
|
121
|
+
|
122
|
+
Executions:
|
123
|
+
|
124
|
+
$ ruby integer.rb --integer 100
|
125
|
+
[100, Integer]
|
126
|
+
$ ruby integer.rb --integer -100
|
127
|
+
[-100, Integer]
|
128
|
+
$ ruby integer.rb --integer 0100
|
129
|
+
[64, Integer]
|
130
|
+
$ ruby integer.rb --integer 0x100
|
131
|
+
[256, Integer]
|
132
|
+
$ ruby integer.rb --integer 0b100
|
133
|
+
[4, Integer]
|
134
|
+
|
135
|
+
==== \Float
|
136
|
+
|
137
|
+
File +float.rb+
|
138
|
+
defines an option whose argument is to be converted to a \Float object.
|
139
|
+
The argument is converted by method Kernel#Float.
|
140
|
+
|
141
|
+
:include: ruby/float.rb
|
142
|
+
|
143
|
+
Executions:
|
144
|
+
|
145
|
+
$ ruby float.rb --float 1
|
146
|
+
[1.0, Float]
|
147
|
+
$ ruby float.rb --float 3.14159
|
148
|
+
[3.14159, Float]
|
149
|
+
$ ruby float.rb --float 1.234E2
|
150
|
+
[123.4, Float]
|
151
|
+
$ ruby float.rb --float 1.234E-2
|
152
|
+
[0.01234, Float]
|
153
|
+
|
154
|
+
==== \Numeric
|
155
|
+
|
156
|
+
File +numeric.rb+
|
157
|
+
defines an option whose argument is to be converted to an instance
|
158
|
+
of \Rational, \Float, or \Integer.
|
159
|
+
The argument is converted by method Kernel#Rational,
|
160
|
+
Kernel#Float, or Kernel#Integer.
|
161
|
+
|
162
|
+
:include: ruby/numeric.rb
|
163
|
+
|
164
|
+
Executions:
|
165
|
+
|
166
|
+
$ ruby numeric.rb --numeric 1/3
|
167
|
+
[(1/3), Rational]
|
168
|
+
$ ruby numeric.rb --numeric 3.333E-1
|
169
|
+
[0.3333, Float]
|
170
|
+
$ ruby numeric.rb --numeric 3
|
171
|
+
[3, Integer]
|
172
|
+
|
173
|
+
==== \DecimalInteger
|
174
|
+
|
175
|
+
File +decimal_integer.rb+
|
176
|
+
defines an option whose argument is to be converted to an \Integer object.
|
177
|
+
The argument is converted by method Kernel#Integer.
|
178
|
+
|
179
|
+
:include: ruby/decimal_integer.rb
|
180
|
+
|
181
|
+
The argument may not be in a binary or hexadecimal format;
|
182
|
+
a leading zero is ignored (not parsed as octal).
|
183
|
+
|
184
|
+
Executions:
|
185
|
+
|
186
|
+
$ ruby decimal_integer.rb --decimal_integer 100
|
187
|
+
[100, Integer]
|
188
|
+
$ ruby decimal_integer.rb --decimal_integer -100
|
189
|
+
[-100, Integer]
|
190
|
+
$ ruby decimal_integer.rb --decimal_integer 0100
|
191
|
+
[100, Integer]
|
192
|
+
$ ruby decimal_integer.rb --decimal_integer -0100
|
193
|
+
[-100, Integer]
|
194
|
+
|
195
|
+
==== \OctalInteger
|
196
|
+
|
197
|
+
File +octal_integer.rb+
|
198
|
+
defines an option whose argument is to be converted to an \Integer object.
|
199
|
+
The argument is converted by method Kernel#Integer.
|
200
|
+
|
201
|
+
:include: ruby/octal_integer.rb
|
202
|
+
|
203
|
+
The argument may not be in a binary or hexadecimal format;
|
204
|
+
it is parsed as octal, regardless of whether it has a leading zero.
|
205
|
+
|
206
|
+
Executions:
|
207
|
+
|
208
|
+
$ ruby octal_integer.rb --octal_integer 100
|
209
|
+
[64, Integer]
|
210
|
+
$ ruby octal_integer.rb --octal_integer -100
|
211
|
+
[-64, Integer]
|
212
|
+
$ ruby octal_integer.rb --octal_integer 0100
|
213
|
+
[64, Integer]
|
214
|
+
|
215
|
+
==== \DecimalNumeric
|
216
|
+
|
217
|
+
File +decimal_numeric.rb+
|
218
|
+
defines an option whose argument is to be converted to an \Integer object.
|
219
|
+
The argument is converted by method Kernel#Integer
|
220
|
+
|
221
|
+
:include: ruby/decimal_numeric.rb
|
222
|
+
|
223
|
+
The argument may not be in a binary or hexadecimal format;
|
224
|
+
a leading zero causes the argument to be parsed as octal.
|
225
|
+
|
226
|
+
Executions:
|
227
|
+
|
228
|
+
$ ruby decimal_numeric.rb --decimal_numeric 100
|
229
|
+
[100, Integer]
|
230
|
+
$ ruby decimal_numeric.rb --decimal_numeric -100
|
231
|
+
[-100, Integer]
|
232
|
+
$ ruby decimal_numeric.rb --decimal_numeric 0100
|
233
|
+
[64, Integer]
|
234
|
+
|
235
|
+
==== \TrueClass
|
236
|
+
|
237
|
+
File +true_class.rb+
|
238
|
+
defines an option whose argument is to be converted to +true+ or +false+.
|
239
|
+
The argument is evaluated by method Object#nil?.
|
240
|
+
|
241
|
+
:include: ruby/true_class.rb
|
242
|
+
|
243
|
+
The argument may be any of those shown in the examples below.
|
244
|
+
|
245
|
+
Executions:
|
246
|
+
|
247
|
+
$ ruby true_class.rb --true_class true
|
248
|
+
[true, TrueClass]
|
249
|
+
$ ruby true_class.rb --true_class yes
|
250
|
+
[true, TrueClass]
|
251
|
+
$ ruby true_class.rb --true_class +
|
252
|
+
[true, TrueClass]
|
253
|
+
$ ruby true_class.rb --true_class false
|
254
|
+
[false, FalseClass]
|
255
|
+
$ ruby true_class.rb --true_class no
|
256
|
+
[false, FalseClass]
|
257
|
+
$ ruby true_class.rb --true_class -
|
258
|
+
[false, FalseClass]
|
259
|
+
$ ruby true_class.rb --true_class nil
|
260
|
+
[false, FalseClass]
|
261
|
+
|
262
|
+
==== \FalseClass
|
263
|
+
|
264
|
+
File +false_class.rb+
|
265
|
+
defines an option whose argument is to be converted to +true+ or +false+.
|
266
|
+
The argument is evaluated by method Object#nil?.
|
267
|
+
|
268
|
+
:include: ruby/false_class.rb
|
269
|
+
|
270
|
+
The argument may be any of those shown in the examples below.
|
271
|
+
|
272
|
+
Executions:
|
273
|
+
|
274
|
+
$ ruby false_class.rb --false_class false
|
275
|
+
[false, FalseClass]
|
276
|
+
$ ruby false_class.rb --false_class no
|
277
|
+
[false, FalseClass]
|
278
|
+
$ ruby false_class.rb --false_class -
|
279
|
+
[false, FalseClass]
|
280
|
+
$ ruby false_class.rb --false_class nil
|
281
|
+
[false, FalseClass]
|
282
|
+
$ ruby false_class.rb --false_class true
|
283
|
+
[true, TrueClass]
|
284
|
+
$ ruby false_class.rb --false_class yes
|
285
|
+
[true, TrueClass]
|
286
|
+
$ ruby false_class.rb --false_class +
|
287
|
+
[true, TrueClass]
|
288
|
+
|
289
|
+
==== \Object
|
290
|
+
|
291
|
+
File +object.rb+
|
292
|
+
defines an option whose argument is not to be converted from \String.
|
293
|
+
|
294
|
+
:include: ruby/object.rb
|
295
|
+
|
296
|
+
Executions:
|
297
|
+
|
298
|
+
$ ruby object.rb --object foo
|
299
|
+
["foo", String]
|
300
|
+
$ ruby object.rb --object nil
|
301
|
+
["nil", String]
|
302
|
+
|
303
|
+
==== \String
|
304
|
+
|
305
|
+
File +string.rb+
|
306
|
+
defines an option whose argument is not to be converted from \String.
|
307
|
+
|
308
|
+
:include: ruby/string.rb
|
309
|
+
|
310
|
+
Executions:
|
311
|
+
|
312
|
+
$ ruby string.rb --string foo
|
313
|
+
["foo", String]
|
314
|
+
$ ruby string.rb --string nil
|
315
|
+
["nil", String]
|
316
|
+
|
317
|
+
==== \Array
|
318
|
+
|
319
|
+
File +array.rb+
|
320
|
+
defines an option whose argument is to be converted from \String
|
321
|
+
to an array of strings, based on comma-separated substrings.
|
322
|
+
|
323
|
+
:include: ruby/array.rb
|
324
|
+
|
325
|
+
Executions:
|
326
|
+
|
327
|
+
$ ruby array.rb --array ""
|
328
|
+
[[], Array]
|
329
|
+
$ ruby array.rb --array foo,bar,baz
|
330
|
+
[["foo", "bar", "baz"], Array]
|
331
|
+
$ ruby array.rb --array "foo, bar, baz"
|
332
|
+
[["foo", " bar", " baz"], Array]
|
333
|
+
|
334
|
+
==== \Regexp
|
335
|
+
|
336
|
+
File +regexp.rb+
|
337
|
+
defines an option whose argument is to be converted to a \Regexp object.
|
338
|
+
|
339
|
+
:include: ruby/regexp.rb
|
340
|
+
|
341
|
+
Executions:
|
342
|
+
|
343
|
+
$ ruby regexp.rb --regexp foo
|
344
|
+
|
345
|
+
=== Custom Argument Converters
|
346
|
+
|
347
|
+
You can create custom argument converters.
|
348
|
+
To create a custom converter, call OptionParser#accept with:
|
349
|
+
|
350
|
+
- An identifier, which may be any object.
|
351
|
+
- An optional match pattern, which defaults to <tt>/.*/m</tt>.
|
352
|
+
- A block that accepts the argument and returns the converted value.
|
353
|
+
|
354
|
+
This custom converter accepts any argument and converts it,
|
355
|
+
if possible, to a \Complex object.
|
356
|
+
|
357
|
+
:include: ruby/custom_converter.rb
|
358
|
+
|
359
|
+
Executions:
|
360
|
+
|
361
|
+
$ ruby custom_converter.rb --complex 0
|
362
|
+
[(0+0i), Complex]
|
363
|
+
$ ruby custom_converter.rb --complex 1
|
364
|
+
[(1+0i), Complex]
|
365
|
+
$ ruby custom_converter.rb --complex 1+2i
|
366
|
+
[(1+2i), Complex]
|
367
|
+
$ ruby custom_converter.rb --complex 0.3-0.5i
|
368
|
+
[(0.3-0.5i), Complex]
|
369
|
+
|
370
|
+
This custom converter accepts any 1-word argument
|
371
|
+
and capitalizes it, if possible.
|
372
|
+
|
373
|
+
:include: ruby/match_converter.rb
|
374
|
+
|
375
|
+
Executions:
|
376
|
+
|
377
|
+
$ ruby match_converter.rb --capitalize foo
|
378
|
+
["Foo", String]
|
379
|
+
$ ruby match_converter.rb --capitalize "foo bar"
|
380
|
+
match_converter.rb:9:in `<main>': invalid argument: --capitalize foo bar (OptionParser::InvalidArgument)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Creates an option from the given parameters +params+.
|
2
|
+
See {Parameters for New Options}[optparse/option_params.rdoc].
|
3
|
+
|
4
|
+
The block, if given, is the handler for the created option.
|
5
|
+
When the option is encountered during command-line parsing,
|
6
|
+
the block is called with the argument given for the option, if any.
|
7
|
+
See {Option Handlers}[optparse/option_params.rdoc#label-Option+Handlers].
|