optparse 0.1.1 → 0.2.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 +264 -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/kwargs.rb +2 -0
- data/lib/optparse.rb +33 -75
- metadata +62 -7
- 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: 45145f867a14905754ed4e60fa3a217e5dd141afac7763be973a90aa488a4e1d
|
4
|
+
data.tar.gz: 925392a4e752b2fd4dbd2a26b9446e580c4c2e375611659d705b7f685b149c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cbaf965329a82b9ec5ba8af7f4f56e4e91b54f4dfc524d0a1aa3abe4a72f5f2bb64af95d2a1d504bb3dd4cb24243dcf8aa346fbd14caf9959045bb9edf2d73b
|
7
|
+
data.tar.gz: 8e3c1ee8582ad9b524db35a864c0eafd4adcf4dd6475bb8c2faa6cad0aad1f3fe17617a681fb4319f632fa205a175be45f29920eeca9404a8b662f41565edb64
|
data/ChangeLog
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
-*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
commit 1226b670e60d5ec8ad4c1a6b73040c9fdcf40fe2
|
4
|
+
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
5
|
+
AuthorDate: 2021-10-21 20:38:56 +0900
|
6
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
7
|
+
CommitDate: 2021-10-21 20:38:56 +0900
|
8
|
+
|
9
|
+
Bump up optparse version to 0.2.0
|
10
|
+
|
11
|
+
commit 0281b949c6cf86806a260ca6b39267d9b202fbf8
|
12
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
13
|
+
AuthorDate: 2021-09-29 11:45:11 +0900
|
14
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
15
|
+
CommitDate: 2021-09-29 11:45:11 +0900
|
16
|
+
|
17
|
+
Add the argument from where synchronize tools
|
18
|
+
|
19
|
+
commit a3d05c1be8efb552b64f3d1af84b8b8dea8e0afb
|
20
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
21
|
+
AuthorDate: 2021-09-29 11:34:44 +0900
|
22
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
23
|
+
CommitDate: 2021-09-29 11:34:44 +0900
|
24
|
+
|
25
|
+
Revived `rdoc` task
|
26
|
+
|
27
|
+
commit 6a2fa9737f5dab99c73a99a24472f620fff228ea
|
28
|
+
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
29
|
+
AuthorDate: 2021-09-11 13:21:00 +0900
|
30
|
+
Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
|
31
|
+
CommitDate: 2021-09-11 13:21:00 +0900
|
32
|
+
|
33
|
+
Bump up the latest version of CoreAssertions
|
34
|
+
|
35
|
+
commit bf03038d953902569c11448717ab584c65e35a89
|
36
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
37
|
+
AuthorDate: 2021-04-22 14:22:11 -0500
|
38
|
+
Commit: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
39
|
+
CommitDate: 2021-04-22 14:22:11 -0500
|
40
|
+
|
41
|
+
Fix link in included file
|
42
|
+
|
43
|
+
commit 47417f1b4cb5d819aa54f305a4009f45d7a112c1
|
44
|
+
Author: Olle Jonsson <olle.jonsson@gmail.com>
|
45
|
+
AuthorDate: 2021-04-23 13:04:25 +0200
|
46
|
+
Commit: GitHub <noreply@github.com>
|
47
|
+
CommitDate: 2021-04-23 06:04:25 -0500
|
48
|
+
|
49
|
+
Remove an errant { character (#26)
|
50
|
+
|
51
|
+
commit 40d51ccbad75ab5194ce5a3574b49fda41745849
|
52
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
53
|
+
AuthorDate: 2021-04-22 08:48:23 -0500
|
54
|
+
Commit: GitHub <noreply@github.com>
|
55
|
+
CommitDate: 2021-04-22 08:48:23 -0500
|
56
|
+
|
57
|
+
More on tutorial (#24)
|
58
|
+
|
59
|
+
- Adds section "Parsing" to tutorial.rdoc.
|
60
|
+
- Removes section "Terminators" from option_params.rdoc. (Terminator '--' is not an option parameter.)
|
61
|
+
|
62
|
+
commit 7f3195b9dbc3a984a5d3e928a9d70686484411c0
|
63
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
64
|
+
AuthorDate: 2021-04-22 07:27:06 -0500
|
65
|
+
Commit: GitHub <noreply@github.com>
|
66
|
+
CommitDate: 2021-04-22 07:27:06 -0500
|
67
|
+
|
68
|
+
More on tutorial (#23)
|
69
|
+
|
70
|
+
- Removed a largish block of repeated text.
|
71
|
+
- Added sections "Top List and Base List" and "Methods for Defining Options" (on, define, etc.).
|
72
|
+
- Linked from class OptionParser doc to the tutorial.
|
73
|
+
|
74
|
+
commit 7ef3d89e7859552daa057b6d5f42ffe3e562ae34
|
75
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
76
|
+
AuthorDate: 2021-04-16 12:57:55 +0900
|
77
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
78
|
+
CommitDate: 2021-04-16 12:57:55 +0900
|
79
|
+
|
80
|
+
Removed a duplicate section
|
81
|
+
|
82
|
+
commit 9c5b3f244b723e0231ef07c56c59dabf56a9dd3f
|
83
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
84
|
+
AuthorDate: 2021-04-15 09:32:02 -0500
|
85
|
+
Commit: GitHub <noreply@github.com>
|
86
|
+
CommitDate: 2021-04-15 09:32:02 -0500
|
87
|
+
|
88
|
+
More on tutorial (#22)
|
89
|
+
|
90
|
+
Adds argument abbreviation in option_params.rdoc.
|
91
|
+
Adds entire Argument Values section to tutorial.rdoc.
|
92
|
+
|
93
|
+
commit d07cb96a9616ae7489e41db7bb85e43a9b664831
|
94
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
95
|
+
AuthorDate: 2021-04-12 20:33:19 -0500
|
96
|
+
Commit: GitHub <noreply@github.com>
|
97
|
+
CommitDate: 2021-04-13 10:33:19 +0900
|
98
|
+
|
99
|
+
Rdoc for help (#21)
|
100
|
+
|
101
|
+
commit 385dd4322de67a989e5d271ed7ddb96b2375956f
|
102
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
103
|
+
AuthorDate: 2021-04-11 23:43:02 -0500
|
104
|
+
Commit: GitHub <noreply@github.com>
|
105
|
+
CommitDate: 2021-04-12 06:43:02 +0200
|
106
|
+
|
107
|
+
Tutorial: explain custom argument converters (#19)
|
108
|
+
|
109
|
+
commit f23d750d14936c0e3663f65ad1b97be82d232dae
|
110
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
111
|
+
AuthorDate: 2021-04-12 02:02:11 +0900
|
112
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
113
|
+
CommitDate: 2021-04-12 02:02:11 +0900
|
114
|
+
|
115
|
+
nodoc private methods
|
116
|
+
|
117
|
+
commit 7e65ef3cfa3a38aaac3a61e1a82307427f1d27c1
|
118
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
119
|
+
AuthorDate: 2021-04-12 00:38:40 +0900
|
120
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
121
|
+
CommitDate: 2021-04-12 00:38:40 +0900
|
122
|
+
|
123
|
+
Fixed mismatched <tt> tag
|
124
|
+
|
125
|
+
commit cccb28e0debbf0f96162291766d3ccafc2c558a3
|
126
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
127
|
+
AuthorDate: 2021-04-11 09:03:07 +0900
|
128
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
129
|
+
CommitDate: 2021-04-11 09:03:07 +0900
|
130
|
+
|
131
|
+
Moved rdoc files to doc/optparse
|
132
|
+
|
133
|
+
commit 8be031b5392cb440f3df23304805c8c814265c59
|
134
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
135
|
+
AuthorDate: 2021-04-11 08:49:30 +0900
|
136
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
137
|
+
CommitDate: 2021-04-11 08:51:44 +0900
|
138
|
+
|
139
|
+
Fix relative paths
|
140
|
+
|
141
|
+
commit 01c24ca4f606a455b8d135a48e11a0371ef6d7c0
|
142
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
143
|
+
AuthorDate: 2021-04-11 08:24:03 +0900
|
144
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
145
|
+
CommitDate: 2021-04-11 08:24:03 +0900
|
146
|
+
|
147
|
+
Added `rdoc` task
|
148
|
+
|
149
|
+
commit 4ff48f24c9b44740dd6c63bc5005db8959c21f80
|
150
|
+
Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
151
|
+
AuthorDate: 2021-04-09 23:20:03 +0900
|
152
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
153
|
+
CommitDate: 2021-04-11 08:10:41 +0900
|
154
|
+
|
155
|
+
No document in rakelib
|
156
|
+
|
157
|
+
commit 39d39676c45083953a082c4f6e2e8a7315b7066d
|
158
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
159
|
+
AuthorDate: 2021-04-10 16:30:19 -0500
|
160
|
+
Commit: GitHub <noreply@github.com>
|
161
|
+
CommitDate: 2021-04-10 16:30:19 -0500
|
162
|
+
|
163
|
+
More on tutorial (#16)
|
164
|
+
|
165
|
+
- Added example in "Argument Converters"; it doesn't seem right for a tutorial to have no example in one of its topics (and instead just linking elsewhere).
|
166
|
+
- Added section "Command-Line Abbreviations."
|
167
|
+
- Added section "Keyword Argument into," showing how to:
|
168
|
+
- Collect options.
|
169
|
+
- Check for missing options.
|
170
|
+
- Provide option defaults.
|
171
|
+
|
172
|
+
commit c91ed8d33db7355cf0a5a8323f3f6aad57e18b38
|
173
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
174
|
+
AuthorDate: 2021-04-10 10:05:44 -0500
|
175
|
+
Commit: GitHub <noreply@github.com>
|
176
|
+
CommitDate: 2021-04-10 10:05:44 -0500
|
177
|
+
|
178
|
+
Rdoc (#15)
|
179
|
+
|
180
|
+
* Resolve shared mixed_names.rb
|
181
|
+
|
182
|
+
* Add long option with negation
|
183
|
+
|
184
|
+
* Show --help for all examples
|
185
|
+
|
186
|
+
* Table of contents for tutorial
|
187
|
+
|
188
|
+
* Move argument converters to separate rdoc
|
189
|
+
|
190
|
+
* Add references to argument_converters.rdoc
|
191
|
+
|
192
|
+
* Tune up argument converters
|
193
|
+
|
194
|
+
* Change explicit links to auto-links
|
195
|
+
|
196
|
+
commit 9a2352c1c9c3445d1618da577f19137243a2a748
|
197
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
198
|
+
AuthorDate: 2021-04-09 08:21:34 -0500
|
199
|
+
Commit: GitHub <noreply@github.com>
|
200
|
+
CommitDate: 2021-04-09 08:21:34 -0500
|
201
|
+
|
202
|
+
Reorganize Ruby example files for sharing (#14)
|
203
|
+
|
204
|
+
commit f3ca83caff20f6daf07a70a3f3f41a6666790b6c
|
205
|
+
Author: Olle Jonsson <olle.jonsson@gmail.com>
|
206
|
+
AuthorDate: 2021-04-08 05:33:56 +0200
|
207
|
+
Commit: GitHub <noreply@github.com>
|
208
|
+
CommitDate: 2021-04-08 12:33:56 +0900
|
209
|
+
|
210
|
+
gemspec: Explicit files list (#10)
|
211
|
+
|
212
|
+
This avoid shelling out, and includes a narrower list of files.
|
213
|
+
|
214
|
+
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
215
|
+
|
216
|
+
commit d55d9284c3a02a794d63a842764591d4ff079241
|
217
|
+
Author: BurdetteLamar <burdettelamar@yahoo.com>
|
218
|
+
AuthorDate: 2021-04-07 11:58:46 -0500
|
219
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
220
|
+
CommitDate: 2021-04-08 10:40:59 +0900
|
221
|
+
|
222
|
+
Make use of option_params.rdoc
|
223
|
+
|
224
|
+
commit 5618eeb49ee2a316cd5d91a515dbb2734f553027
|
225
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
226
|
+
AuthorDate: 2021-04-07 09:01:52 -0500
|
227
|
+
Commit: GitHub <noreply@github.com>
|
228
|
+
CommitDate: 2021-04-07 16:01:52 +0200
|
229
|
+
|
230
|
+
Enhanced doc for option parameters (#11)
|
231
|
+
|
232
|
+
commit 84dfd92d2a7fb75bb40fbb8414bd8b90b7ccbac6
|
233
|
+
Author: Burdette Lamar <BurdetteLamar@Yahoo.com>
|
234
|
+
AuthorDate: 2021-04-06 13:55:21 -0500
|
235
|
+
Commit: GitHub <noreply@github.com>
|
236
|
+
CommitDate: 2021-04-06 13:55:21 -0500
|
237
|
+
|
238
|
+
More on tutorial (#9)
|
239
|
+
|
240
|
+
* More on tutorial
|
241
|
+
|
242
|
+
* More on tutorial
|
243
|
+
|
244
|
+
* More on tutorial
|
245
|
+
|
246
|
+
* More on tutorial: clearer example output
|
247
|
+
|
248
|
+
commit d14bf830078c2b2c8c8bcbe60aa2a2ebb40e0b6c
|
249
|
+
Author: Olle Jonsson <olle.jonsson@gmail.com>
|
250
|
+
AuthorDate: 2021-04-06 10:01:37 +0200
|
251
|
+
Commit: GitHub <noreply@github.com>
|
252
|
+
CommitDate: 2021-04-06 10:01:37 +0200
|
253
|
+
|
254
|
+
gemspec: Explicitly list 0 executables
|
255
|
+
|
256
|
+
This gem exposes no executable files.
|
257
|
+
|
258
|
+
commit f209276f79d84578d4e40004ce7768194aae00cc
|
259
|
+
Author: BurdetteLamar <burdettelamar@yahoo.com>
|
260
|
+
AuthorDate: 2021-03-29 14:03:04 -0500
|
261
|
+
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
262
|
+
CommitDate: 2021-03-30 12:00:31 +0900
|
263
|
+
|
264
|
+
Beginnings of tutorial
|
@@ -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}[./doc/optparse/option_params_rdoc.html].
|
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}[./option_params_rdoc.html#label-Option+Handlers].
|