optparse 0.3.1 → 0.4.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: 3726480fe0a25a9efd1cec645f993256cda45ac050411f046dfb6fa35117414a
4
- data.tar.gz: ace5491689e1e277cd9b0a37b7ff070be46e46b6cb1b3b21f19c02d4d2d792a1
3
+ metadata.gz: 393ddfd5f19439c98112418ff879314c8570d9955e4a26a148b6d3bd94354cda
4
+ data.tar.gz: 270b3538983dfd6920cae9b2fcda5d7dcb5304157ae1e323a0d56daf33a6dd60
5
5
  SHA512:
6
- metadata.gz: af882a7ff3c55fc882fbbc1259d104a55dd15049b64b3022459e868c4a00ba989ac651b5f7c16a260a97c8f4992b07adc3b03ca23ad231adf46cae62be6ae8b6
7
- data.tar.gz: 42d6f1e638d8fdbb43953e0ecda55a00b9460d375a1cb8175bd14dcdbbc2fd94996fae031b0b7f31881d73dc6fa2815c75d146fc2fedc2ea9551797118be22e5
6
+ metadata.gz: 80e82b866fccf4b8598d3b495941629255ddfa907a8686a092d9ab5135d145d1c0a83d9d3d42ededcf1d33e21bc5ea6bfbee79f40085140e29a4ac54e6b96a1d
7
+ data.tar.gz: 998881fc6568b9725d7874145111cdee53e2366050a63f0e5908395f183d080eda16bf6740e8d83f90fe60064cf85fb424c24cd70e4589b344ee9dc3b997d283
data/ChangeLog CHANGED
@@ -1,25 +1,163 @@
1
1
  -*- coding: utf-8 -*-
2
2
 
3
- commit 2a1e157ae134b07b8412182502755ec4eb3af499
3
+ commit acbf6e3e12de4d116f7215b64432f204d293da97
4
4
  Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
5
- AuthorDate: 2022-12-22 17:47:34 +0900
5
+ AuthorDate: 2023-11-07 10:40:38 +0900
6
6
  Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
7
- CommitDate: 2022-12-22 17:47:34 +0900
7
+ CommitDate: 2023-11-07 10:40:38 +0900
8
8
 
9
- Bump version to 0.3.1
9
+ Bump up 0.4.0
10
10
 
11
- commit 766f567405a362d0e018d8411df15ce8d70573a6
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
16
+
17
+ Use test-unit-ruby-core gem
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
24
+
25
+ Bump actions/checkout from 3 to 4
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)
31
+
32
+ ---
33
+ updated-dependencies:
34
+ - dependency-name: actions/checkout
35
+ dependency-type: direct:production
36
+ update-type: version-update:semver-major
37
+ ...
38
+
39
+ Signed-off-by: dependabot[bot] <support@github.com>
40
+
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
46
+
47
+ [DOC] Corrections to tutorial
48
+
49
+ commit e8bee0be8f52f5a3e08d0db09a13798701670391
12
50
  Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
13
- AuthorDate: 2022-12-21 14:07:54 +0900
14
- Commit: GitHub <noreply@github.com>
15
- CommitDate: 2022-12-21 14:07:54 +0900
51
+ AuthorDate: 2023-07-30 11:24:59 +0900
52
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
53
+ CommitDate: 2023-07-30 11:24:59 +0900
54
+
55
+ [DOC] Mark up constant and method names as code
16
56
 
17
- The encoding argument of `Regexp.new` has been ignored since 1.9
57
+ commit 3cde2178d3d1bd1c7bf9c7e2af930e89e0bad6e5
58
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
59
+ AuthorDate: 2023-07-12 01:07:11 +0900
60
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
61
+ CommitDate: 2023-07-12 01:07:37 +0900
62
+
63
+ Upload according to build results
64
+
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
70
+
71
+ Document requires needed for Date/DateTime/Time/URI/Shellwords support
72
+
73
+ Fixes [Bug #19566]
74
+
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
18
80
 
19
- commit 97a198673408d98686a4ec9c3457eef13088c981
20
- Author: Junichi Sato <22004610+sato11@users.noreply.github.com>
21
- AuthorDate: 2022-12-07 15:02:23 +0900
81
+ Update test libraries from https://github.com/ruby/ruby/commit/b4e438d8aabaf4bba2b27f374c787543fae07c58
82
+
83
+ commit b67cc2407e6f9b5b4c9bc0751e21fa4969da0ceb
84
+ Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
85
+ AuthorDate: 2023-02-18 16:37:54 +0900
22
86
  Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
23
- CommitDate: 2022-12-08 12:11:51 +0900
87
+ CommitDate: 2023-02-18 16:46:18 +0900
88
+
89
+ Skip build and upload package with Windows
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
96
+
97
+ Exclude JRuby from Windows
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
104
+
105
+ Try with Windows
106
+
107
+ commit 45fade52f519f656f62eb601899e3e96d3f69fca
108
+ Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
109
+ AuthorDate: 2023-02-18 16:25:25 +0900
110
+ Commit: Hiroshi SHIBATA <hsbt@ruby-lang.org>
111
+ CommitDate: 2023-02-18 16:46:18 +0900
112
+
113
+ Use ruby/actions/.github/workflows/ruby_versions.yml@master
114
+
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
120
+
121
+ Migrate set-output to $GITHUB_OUTPUT (#50)
122
+
123
+ https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
124
+
125
+ commit 3e63d878f895a299a6ddeee5f8c615b69edf401c
126
+ Author: Junichi Ito <jit@sonicgarden.jp>
127
+ AuthorDate: 2022-11-29 08:07:47 +0900
128
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
129
+ CommitDate: 2022-12-22 19:58:43 +0900
130
+
131
+ Add symbolize_names to getopts
132
+
133
+ commit 73661899ad17e1061c7fc0f88cc4ac4e66a3c9a9
134
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
135
+ AuthorDate: 2022-12-22 19:57:30 +0900
136
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
137
+ CommitDate: 2022-12-22 19:57:30 +0900
138
+
139
+ bump up to 0.4.0.pre.1
140
+
141
+ commit 697ea7bf8e343704e735fb2d1f7787d96b843469
142
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
143
+ AuthorDate: 2022-12-22 19:55:51 +0900
144
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
145
+ CommitDate: 2022-12-22 19:55:51 +0900
146
+
147
+ Add .rdoc_options
148
+
149
+ commit ab0022bd23d77e515390cbb2c165f7647400be46
150
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
151
+ AuthorDate: 2021-09-29 11:47:47 +0900
152
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
153
+ CommitDate: 2022-12-22 19:53:20 +0900
154
+
155
+ Cron test
156
+
157
+ commit 33663e2c50eb8496b81750976b3480c14783470d
158
+ Author: Nobuyoshi Nakada <nobu@ruby-lang.org>
159
+ AuthorDate: 2022-12-22 19:48:22 +0900
160
+ Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
161
+ CommitDate: 2022-12-22 19:50:16 +0900
24
162
 
25
- Use GITHUB_OUTPUT instead of deprecated set-output
163
+ Add `helper.bump`
@@ -1,7 +1,7 @@
1
1
  == Argument Converters
2
2
 
3
3
  An option can specify that its argument is to be converted
4
- from the default \String to an instance of another class.
4
+ from the default +String+ to an instance of another class.
5
5
 
6
6
  === Contents
7
7
 
@@ -27,13 +27,13 @@ from the default \String to an instance of another class.
27
27
 
28
28
  === Built-In Argument Converters
29
29
 
30
- \OptionParser has a number of built-in argument converters,
30
+ +OptionParser+ has a number of built-in argument converters,
31
31
  which are demonstrated below.
32
32
 
33
- ==== \Date
33
+ ==== +Date+
34
34
 
35
35
  File +date.rb+
36
- defines an option whose argument is to be converted to a \Date object.
36
+ defines an option whose argument is to be converted to a +Date+ object.
37
37
  The argument is converted by method Date#parse.
38
38
 
39
39
  :include: ruby/date.rb
@@ -47,10 +47,10 @@ Executions:
47
47
  $ ruby date.rb --date "3rd Feb 2001"
48
48
  [#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
49
49
 
50
- ==== \DateTime
50
+ ==== +DateTime+
51
51
 
52
52
  File +datetime.rb+
53
- defines an option whose argument is to be converted to a \DateTime object.
53
+ defines an option whose argument is to be converted to a +DateTime+ object.
54
54
  The argument is converted by method DateTime#parse.
55
55
 
56
56
  :include: ruby/datetime.rb
@@ -64,10 +64,10 @@ Executions:
64
64
  $ ruby datetime.rb --datetime "3rd Feb 2001 04:05:06 PM"
65
65
  [#<DateTime: 2001-02-03T16:05:06+00:00 ((2451944j,57906s,0n),+0s,2299161j)>, DateTime]
66
66
 
67
- ==== \Time
67
+ ==== +Time+
68
68
 
69
69
  File +time.rb+
70
- defines an option whose argument is to be converted to a \Time object.
70
+ defines an option whose argument is to be converted to a +Time+ object.
71
71
  The argument is converted by method Time#httpdate or Time#parse.
72
72
 
73
73
  :include: ruby/time.rb
@@ -79,10 +79,10 @@ Executions:
79
79
  $ ruby time.rb --time 2010-10-31
80
80
  [2010-10-31 00:00:00 -0500, Time]
81
81
 
82
- ==== \URI
82
+ ==== +URI+
83
83
 
84
84
  File +uri.rb+
85
- defines an option whose argument is to be converted to a \URI object.
85
+ defines an option whose argument is to be converted to a +URI+ object.
86
86
  The argument is converted by method URI#parse.
87
87
 
88
88
  :include: ruby/uri.rb
@@ -96,10 +96,10 @@ Executions:
96
96
  $ ruby uri.rb --uri file://~/var
97
97
  [#<URI::File file://~/var>, URI::File]
98
98
 
99
- ==== \Shellwords
99
+ ==== +Shellwords+
100
100
 
101
101
  File +shellwords.rb+
102
- defines an option whose argument is to be converted to an \Array object by method
102
+ defines an option whose argument is to be converted to an +Array+ object by method
103
103
  Shellwords#shellwords.
104
104
 
105
105
  :include: ruby/shellwords.rb
@@ -111,10 +111,10 @@ Executions:
111
111
  $ ruby shellwords.rb --shellwords "here are 'two words'"
112
112
  [["here", "are", "two words"], Array]
113
113
 
114
- ==== \Integer
114
+ ==== +Integer+
115
115
 
116
116
  File +integer.rb+
117
- defines an option whose argument is to be converted to an \Integer object.
117
+ defines an option whose argument is to be converted to an +Integer+ object.
118
118
  The argument is converted by method Kernel#Integer.
119
119
 
120
120
  :include: ruby/integer.rb
@@ -132,10 +132,10 @@ Executions:
132
132
  $ ruby integer.rb --integer 0b100
133
133
  [4, Integer]
134
134
 
135
- ==== \Float
135
+ ==== +Float+
136
136
 
137
137
  File +float.rb+
138
- defines an option whose argument is to be converted to a \Float object.
138
+ defines an option whose argument is to be converted to a +Float+ object.
139
139
  The argument is converted by method Kernel#Float.
140
140
 
141
141
  :include: ruby/float.rb
@@ -151,11 +151,11 @@ Executions:
151
151
  $ ruby float.rb --float 1.234E-2
152
152
  [0.01234, Float]
153
153
 
154
- ==== \Numeric
154
+ ==== +Numeric+
155
155
 
156
156
  File +numeric.rb+
157
157
  defines an option whose argument is to be converted to an instance
158
- of \Rational, \Float, or \Integer.
158
+ of +Rational+, +Float+, or +Integer+.
159
159
  The argument is converted by method Kernel#Rational,
160
160
  Kernel#Float, or Kernel#Integer.
161
161
 
@@ -170,10 +170,10 @@ Executions:
170
170
  $ ruby numeric.rb --numeric 3
171
171
  [3, Integer]
172
172
 
173
- ==== \DecimalInteger
173
+ ==== +DecimalInteger+
174
174
 
175
175
  File +decimal_integer.rb+
176
- defines an option whose argument is to be converted to an \Integer object.
176
+ defines an option whose argument is to be converted to an +Integer+ object.
177
177
  The argument is converted by method Kernel#Integer.
178
178
 
179
179
  :include: ruby/decimal_integer.rb
@@ -192,10 +192,10 @@ Executions:
192
192
  $ ruby decimal_integer.rb --decimal_integer -0100
193
193
  [-100, Integer]
194
194
 
195
- ==== \OctalInteger
195
+ ==== +OctalInteger+
196
196
 
197
197
  File +octal_integer.rb+
198
- defines an option whose argument is to be converted to an \Integer object.
198
+ defines an option whose argument is to be converted to an +Integer+ object.
199
199
  The argument is converted by method Kernel#Integer.
200
200
 
201
201
  :include: ruby/octal_integer.rb
@@ -212,10 +212,10 @@ Executions:
212
212
  $ ruby octal_integer.rb --octal_integer 0100
213
213
  [64, Integer]
214
214
 
215
- ==== \DecimalNumeric
215
+ ==== +DecimalNumeric+
216
216
 
217
217
  File +decimal_numeric.rb+
218
- defines an option whose argument is to be converted to an \Integer object.
218
+ defines an option whose argument is to be converted to an +Integer+ object.
219
219
  The argument is converted by method Kernel#Integer
220
220
 
221
221
  :include: ruby/decimal_numeric.rb
@@ -232,7 +232,7 @@ Executions:
232
232
  $ ruby decimal_numeric.rb --decimal_numeric 0100
233
233
  [64, Integer]
234
234
 
235
- ==== \TrueClass
235
+ ==== +TrueClass+
236
236
 
237
237
  File +true_class.rb+
238
238
  defines an option whose argument is to be converted to +true+ or +false+.
@@ -259,7 +259,7 @@ Executions:
259
259
  $ ruby true_class.rb --true_class nil
260
260
  [false, FalseClass]
261
261
 
262
- ==== \FalseClass
262
+ ==== +FalseClass+
263
263
 
264
264
  File +false_class.rb+
265
265
  defines an option whose argument is to be converted to +true+ or +false+.
@@ -286,10 +286,10 @@ Executions:
286
286
  $ ruby false_class.rb --false_class +
287
287
  [true, TrueClass]
288
288
 
289
- ==== \Object
289
+ ==== +Object+
290
290
 
291
291
  File +object.rb+
292
- defines an option whose argument is not to be converted from \String.
292
+ defines an option whose argument is not to be converted from +String+.
293
293
 
294
294
  :include: ruby/object.rb
295
295
 
@@ -300,10 +300,10 @@ Executions:
300
300
  $ ruby object.rb --object nil
301
301
  ["nil", String]
302
302
 
303
- ==== \String
303
+ ==== +String+
304
304
 
305
305
  File +string.rb+
306
- defines an option whose argument is not to be converted from \String.
306
+ defines an option whose argument is not to be converted from +String+.
307
307
 
308
308
  :include: ruby/string.rb
309
309
 
@@ -314,10 +314,10 @@ Executions:
314
314
  $ ruby string.rb --string nil
315
315
  ["nil", String]
316
316
 
317
- ==== \Array
317
+ ==== +Array+
318
318
 
319
319
  File +array.rb+
320
- defines an option whose argument is to be converted from \String
320
+ defines an option whose argument is to be converted from +String+
321
321
  to an array of strings, based on comma-separated substrings.
322
322
 
323
323
  :include: ruby/array.rb
@@ -331,10 +331,10 @@ Executions:
331
331
  $ ruby array.rb --array "foo, bar, baz"
332
332
  [["foo", " bar", " baz"], Array]
333
333
 
334
- ==== \Regexp
334
+ ==== +Regexp+
335
335
 
336
336
  File +regexp.rb+
337
- defines an option whose argument is to be converted to a \Regexp object.
337
+ defines an option whose argument is to be converted to a +Regexp+ object.
338
338
 
339
339
  :include: ruby/regexp.rb
340
340
 
@@ -352,7 +352,7 @@ To create a custom converter, call OptionParser#accept with:
352
352
  - A block that accepts the argument and returns the converted value.
353
353
 
354
354
  This custom converter accepts any argument and converts it,
355
- if possible, to a \Complex object.
355
+ if possible, to a +Complex+ object.
356
356
 
357
357
  :include: ruby/custom_converter.rb
358
358
 
@@ -1,6 +1,6 @@
1
1
  == Parameters for New Options
2
2
 
3
- Option-creating methods in \OptionParser
3
+ Option-creating methods in +OptionParser+
4
4
  accept arguments that determine the behavior of a new option:
5
5
 
6
6
  - OptionParser#on
@@ -405,7 +405,7 @@ Executions:
405
405
  === Argument Converters
406
406
 
407
407
  An option can specify that its argument is to be converted
408
- from the default \String to an instance of another class.
408
+ from the default +String+ to an instance of another class.
409
409
 
410
410
  There are a number of built-in converters.
411
411
  You can also define custom converters.
@@ -1,10 +1,10 @@
1
1
  == Tutorial
2
2
 
3
- === Why \OptionParser?
3
+ === Why +OptionParser+?
4
4
 
5
5
  When a Ruby program executes, it captures its command-line arguments
6
6
  and options into variable ARGV.
7
- This simple program just prints its \ARGV:
7
+ This simple program just prints its +ARGV+:
8
8
 
9
9
  :include: ruby/argv.rb
10
10
 
@@ -18,7 +18,7 @@ the command-line options.
18
18
 
19
19
  OptionParser offers methods for parsing and handling those options.
20
20
 
21
- With \OptionParser, you can define options so that for each option:
21
+ With +OptionParser+, you can define options so that for each option:
22
22
 
23
23
  - The code that defines the option and code that handles that option
24
24
  are in the same place.
@@ -55,7 +55,7 @@ The class also has method #help, which displays automatically-generated help tex
55
55
  - {Argument Converters}[#label-Argument+Converters]
56
56
  - {Help}[#label-Help]
57
57
  - {Top List and Base List}[#label-Top+List+and+Base+List]
58
- - {Defining Options}[#label-Defining+Options]
58
+ - {Methods for Defining Options}[#label-Methods+for+Defining+Options]
59
59
  - {Parsing}[#label-Parsing]
60
60
  - {Method parse!}[#label-Method+parse-21]
61
61
  - {Method parse}[#label-Method+parse]
@@ -66,10 +66,10 @@ The class also has method #help, which displays automatically-generated help tex
66
66
 
67
67
  === To Begin With
68
68
 
69
- To use \OptionParser:
69
+ To use +OptionParser+:
70
70
 
71
- 1. Require the \OptionParser code.
72
- 2. Create an \OptionParser object.
71
+ 1. Require the +OptionParser+ code.
72
+ 2. Create an +OptionParser+ object.
73
73
  3. Define one or more options.
74
74
  4. Parse the command line.
75
75
 
@@ -92,9 +92,9 @@ the block defined for the option is called with the argument value.
92
92
  An invalid option raises an exception.
93
93
 
94
94
  Method #parse!, which is used most often in this tutorial,
95
- removes from \ARGV the options and arguments it finds,
95
+ removes from +ARGV+ the options and arguments it finds,
96
96
  leaving other non-option arguments for the program to handle on its own.
97
- The method returns the possibly-reduced \ARGV array.
97
+ The method returns the possibly-reduced +ARGV+ array.
98
98
 
99
99
  Executions:
100
100
 
@@ -115,7 +115,7 @@ Executions:
115
115
 
116
116
  === Defining Options
117
117
 
118
- A common way to define an option in \OptionParser
118
+ A common way to define an option in +OptionParser+
119
119
  is with instance method OptionParser#on.
120
120
 
121
121
  The method may be called with any number of arguments
@@ -522,11 +522,11 @@ Executions:
522
522
  === Argument Converters
523
523
 
524
524
  An option can specify that its argument is to be converted
525
- from the default \String to an instance of another class.
525
+ from the default +String+ to an instance of another class.
526
526
  There are a number of built-in converters.
527
527
 
528
528
  Example: File +date.rb+
529
- defines an option whose argument is to be converted to a \Date object.
529
+ defines an option whose argument is to be converted to a +Date+ object.
530
530
  The argument is converted by method Date#parse.
531
531
 
532
532
  :include: ruby/date.rb
@@ -546,7 +546,7 @@ for both built-in and custom converters.
546
546
 
547
547
  === Help
548
548
 
549
- \OptionParser makes automatically generated help text available.
549
+ +OptionParser+ makes automatically generated help text available.
550
550
 
551
551
  The help text consists of:
552
552
 
@@ -614,49 +614,49 @@ Execution:
614
614
 
615
615
  === Top List and Base List
616
616
 
617
- An \OptionParser object maintains a stack of \OptionParser::List objects,
617
+ An +OptionParser+ object maintains a stack of OptionParser::List objects,
618
618
  each of which has a collection of zero or more options.
619
619
  It is unlikely that you'll need to add or take away from that stack.
620
620
 
621
621
  The stack includes:
622
622
 
623
- - The <em>top list</em>, given by \OptionParser#top.
624
- - The <em>base list</em>, given by \OptionParser#base.
623
+ - The <em>top list</em>, given by OptionParser#top.
624
+ - The <em>base list</em>, given by OptionParser#base.
625
625
 
626
- When \OptionParser builds its help text, the options in the top list
626
+ When +OptionParser+ builds its help text, the options in the top list
627
627
  precede those in the base list.
628
628
 
629
- === Defining Options
629
+ === Methods for Defining Options
630
630
 
631
631
  Option-defining methods allow you to create an option, and also append/prepend it
632
632
  to the top list or append it to the base list.
633
633
 
634
634
  Each of these next three methods accepts a sequence of parameter arguments and a block,
635
- creates an option object using method \Option#make_switch (see below),
635
+ creates an option object using method OptionParser#make_switch (see below),
636
636
  and returns the created option:
637
637
 
638
- - \Method \OptionParser#define appends the created option to the top list.
638
+ - \Method OptionParser#define appends the created option to the top list.
639
639
 
640
- - \Method \OptionParser#define_head prepends the created option to the top list.
640
+ - \Method OptionParser#define_head prepends the created option to the top list.
641
641
 
642
- - \Method \OptionParser#define_tail appends the created option to the base list.
642
+ - \Method OptionParser#define_tail appends the created option to the base list.
643
643
 
644
644
  These next three methods are identical to the three above,
645
645
  except for their return values:
646
646
 
647
- - \Method \OptionParser#on is identical to method \OptionParser#define,
647
+ - \Method OptionParser#on is identical to method OptionParser#define,
648
648
  except that it returns the parser object +self+.
649
649
 
650
- - \Method \OptionParser#on_head is identical to method \OptionParser#define_head,
650
+ - \Method OptionParser#on_head is identical to method OptionParser#define_head,
651
651
  except that it returns the parser object +self+.
652
652
 
653
- - \Method \OptionParser#on_tail is identical to method \OptionParser#define_tail,
653
+ - \Method OptionParser#on_tail is identical to method OptionParser#define_tail,
654
654
  except that it returns the parser object +self+.
655
655
 
656
656
  Though you may never need to call it directly,
657
657
  here's the core method for defining an option:
658
658
 
659
- - \Method \OptionParser#make_switch accepts an array of parameters and a block.
659
+ - \Method OptionParser#make_switch accepts an array of parameters and a block.
660
660
  See {Parameters for New Options}[optparse/option_params.rdoc].
661
661
  This method is unlike others here in that it:
662
662
  - Accepts an <em>array of parameters</em>;
@@ -668,7 +668,7 @@ here's the core method for defining an option:
668
668
 
669
669
  === Parsing
670
670
 
671
- \OptionParser has six instance methods for parsing.
671
+ +OptionParser+ has six instance methods for parsing.
672
672
 
673
673
  Three have names ending with a "bang" (<tt>!</tt>):
674
674
 
@@ -699,9 +699,9 @@ Each of these methods:
699
699
  (see {Keyword Argument into}[#label-Keyword+Argument+into]).
700
700
  - Returns +argv+, possibly with some elements removed.
701
701
 
702
- ==== \Method parse!
702
+ ==== \Method +parse!+
703
703
 
704
- \Method parse!:
704
+ \Method +parse!+:
705
705
 
706
706
  - Accepts an optional array of string arguments +argv+;
707
707
  if not given, +argv+ defaults to the value of OptionParser#default_argv,
@@ -756,9 +756,9 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
756
756
  ["--xxx", true]
757
757
  Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
758
758
 
759
- ==== \Method parse
759
+ ==== \Method +parse+
760
760
 
761
- \Method parse:
761
+ \Method +parse+:
762
762
 
763
763
  - Accepts an array of string arguments
764
764
  _or_ zero or more string arguments.
@@ -810,25 +810,25 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
810
810
  ["--xxx", true]
811
811
  Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
812
812
 
813
- ==== \Method order!
813
+ ==== \Method +order!+
814
814
 
815
815
  Calling method OptionParser#order! gives exactly the same result as
816
816
  calling method OptionParser#parse! with environment variable
817
817
  +POSIXLY_CORRECT+ defined.
818
818
 
819
- ==== \Method order
819
+ ==== \Method +order+
820
820
 
821
821
  Calling method OptionParser#order gives exactly the same result as
822
822
  calling method OptionParser#parse with environment variable
823
823
  +POSIXLY_CORRECT+ defined.
824
824
 
825
- ==== \Method permute!
825
+ ==== \Method +permute!+
826
826
 
827
827
  Calling method OptionParser#permute! gives exactly the same result as
828
828
  calling method OptionParser#parse! with environment variable
829
829
  +POSIXLY_CORRECT+ _not_ defined.
830
830
 
831
- ==== \Method permute
831
+ ==== \Method +permute+
832
832
 
833
833
  Calling method OptionParser#permute gives exactly the same result as
834
834
  calling method OptionParser#parse with environment variable
data/lib/optparse.rb CHANGED
@@ -48,7 +48,7 @@
48
48
  #
49
49
  # == OptionParser
50
50
  #
51
- # === New to \OptionParser?
51
+ # === New to +OptionParser+?
52
52
  #
53
53
  # See the {Tutorial}[optparse/tutorial.rdoc].
54
54
  #
@@ -152,14 +152,14 @@
152
152
  # OptionParser supports the ability to coerce command line arguments
153
153
  # into objects for us.
154
154
  #
155
- # OptionParser comes with a few ready-to-use kinds of type
155
+ # OptionParser comes with a few ready-to-use kinds of type
156
156
  # coercion. They are:
157
157
  #
158
- # - Date -- Anything accepted by +Date.parse+
159
- # - DateTime -- Anything accepted by +DateTime.parse+
160
- # - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+
161
- # - URI -- Anything accepted by +URI.parse+
162
- # - Shellwords -- Anything accepted by +Shellwords.shellwords+
158
+ # - Date -- Anything accepted by +Date.parse+ (need to require +optparse/date+)
159
+ # - DateTime -- Anything accepted by +DateTime.parse+ (need to require +optparse/date+)
160
+ # - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+ (need to require +optparse/time+)
161
+ # - URI -- Anything accepted by +URI.parse+ (need to require +optparse/uri+)
162
+ # - Shellwords -- Anything accepted by +Shellwords.shellwords+ (need to require +optparse/shellwords+)
163
163
  # - String -- Any non-empty string
164
164
  # - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
165
165
  # - Float -- Any float. (e.g. 10, 3.14, -100E+13)
@@ -425,7 +425,7 @@
425
425
  # If you have any questions, file a ticket at http://bugs.ruby-lang.org.
426
426
  #
427
427
  class OptionParser
428
- OptionParser::Version = "0.3.1"
428
+ OptionParser::Version = "0.4.0"
429
429
 
430
430
  # :stopdoc:
431
431
  NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
@@ -1775,7 +1775,16 @@ XXX
1775
1775
  # # params["bar"] = "x" # --bar x
1776
1776
  # # params["zot"] = "z" # --zot Z
1777
1777
  #
1778
- def getopts(*args)
1778
+ # Option +symbolize_names+ (boolean) specifies whether returned Hash keys should be Symbols; defaults to +false+ (use Strings).
1779
+ #
1780
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true)
1781
+ # # params[:a] = true # -a
1782
+ # # params[:b] = "1" # -b1
1783
+ # # params[:foo] = "1" # --foo
1784
+ # # params[:bar] = "x" # --bar x
1785
+ # # params[:zot] = "z" # --zot Z
1786
+ #
1787
+ def getopts(*args, symbolize_names: false)
1779
1788
  argv = Array === args.first ? args.shift : default_argv
1780
1789
  single_options, *long_options = *args
1781
1790
 
@@ -1804,14 +1813,14 @@ XXX
1804
1813
  end
1805
1814
 
1806
1815
  parse_in_order(argv, result.method(:[]=))
1807
- result
1816
+ symbolize_names ? result.transform_keys(&:to_sym) : result
1808
1817
  end
1809
1818
 
1810
1819
  #
1811
1820
  # See #getopts.
1812
1821
  #
1813
- def self.getopts(*args)
1814
- new.getopts(*args)
1822
+ def self.getopts(*args, symbolize_names: false)
1823
+ new.getopts(*args, symbolize_names: symbolize_names)
1815
1824
  end
1816
1825
 
1817
1826
  #
@@ -2289,8 +2298,8 @@ XXX
2289
2298
  # rescue OptionParser::ParseError
2290
2299
  # end
2291
2300
  #
2292
- def getopts(*args)
2293
- options.getopts(self, *args)
2301
+ def getopts(*args, symbolize_names: false)
2302
+ options.getopts(self, *args, symbolize_names: symbolize_names)
2294
2303
  end
2295
2304
 
2296
2305
  #
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.3.1
4
+ version: 0.4.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: 2022-12-22 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: OptionParser is a class for command-line option analysis.
14
14
  email:
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.4.0.dev
118
+ rubygems_version: 3.5.0.dev
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: OptionParser is a class for command-line option analysis.