cri 2.15.6 → 2.15.11

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: 79a5265f39985bdcfc272fda054b0c9351be2e249d14ce8dd85d3cbff3964479
4
- data.tar.gz: 9dcbb3ab7addc6dda23d1419370882401b91747c754e6a39d7777bbfc8e6c354
3
+ metadata.gz: 823a030106960498adbfd77e19f3ef8b30fdfc6b2b592604ced4c875c8ced9f4
4
+ data.tar.gz: 8663621247fffc1be92d538c7cc5d594522e2a350a126236abfe761a15973a5c
5
5
  SHA512:
6
- metadata.gz: 2e5fd6d1a6c496fb1887e99c02255f438b9fa6734180bb2d09d3dbb349f30136ee16007195c2848bdb26d797f38c6d22473beaa06bf7bdc7d86734619955136d
7
- data.tar.gz: c02067bfb085935f46cf8b35c37862a3eac282c1dfe2eb3bc6c6162f1370d4c5bfa390a2d8a80fc536e7207a5031e225c2e7c7a3bdf3ae8efa329c561402f8b2
6
+ metadata.gz: 5a3c3038f8629238aa071a1d7dd94aee5e7f3e85df7fe097a67176c0300c2a69a3dc576da76354056e8d366ca5b6bae0806b5f0cea3f2854c6c88cafb0150bb3
7
+ data.tar.gz: 7d810e46680ee4802db459510635d2c9857aa400794e09d5d43a903e6ffc0edee0221ce17906f216f543892b9f5ac2f0eb71fa447b1771a9e8f12ac159d5bda8
data/Gemfile CHANGED
@@ -5,7 +5,10 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  gem 'coveralls'
8
+ gem 'm', '~> 1.5'
8
9
  gem 'minitest'
9
10
  gem 'rake'
10
11
  gem 'rubocop'
12
+ gem 'rubocop-minitest', '~> 0.10.2'
13
+ gem 'rubocop-rake', '~> 0.5.1'
11
14
  gem 'yard'
@@ -1,57 +1,75 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cri (2.15.6)
4
+ cri (2.15.11)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
9
+ ast (2.4.1)
10
10
  coveralls (0.8.23)
11
11
  json (>= 1.8, < 3)
12
12
  simplecov (~> 0.16.1)
13
13
  term-ansicolor (~> 1.3)
14
14
  thor (>= 0.19.4, < 2.0)
15
15
  tins (~> 1.6)
16
- docile (1.3.1)
17
- jaro_winkler (1.5.2)
18
- json (2.2.0)
19
- minitest (5.11.3)
20
- parallel (1.17.0)
21
- parser (2.6.3.0)
22
- ast (~> 2.4.0)
16
+ docile (1.3.4)
17
+ json (2.5.1)
18
+ m (1.5.1)
19
+ method_source (>= 0.6.7)
20
+ rake (>= 0.9.2.2)
21
+ method_source (1.0.0)
22
+ minitest (5.14.2)
23
+ parallel (1.20.1)
24
+ parser (3.0.0.0)
25
+ ast (~> 2.4.1)
23
26
  rainbow (3.0.0)
24
- rake (12.3.2)
25
- rubocop (0.69.0)
26
- jaro_winkler (~> 1.5.1)
27
+ rake (13.0.3)
28
+ regexp_parser (2.0.3)
29
+ rexml (3.2.4)
30
+ rubocop (1.7.0)
27
31
  parallel (~> 1.10)
28
- parser (>= 2.6)
32
+ parser (>= 2.7.1.5)
29
33
  rainbow (>= 2.2.2, < 4.0)
34
+ regexp_parser (>= 1.8, < 3.0)
35
+ rexml
36
+ rubocop-ast (>= 1.2.0, < 2.0)
30
37
  ruby-progressbar (~> 1.7)
31
- unicode-display_width (>= 1.4.0, < 1.7)
32
- ruby-progressbar (1.10.0)
38
+ unicode-display_width (>= 1.4.0, < 2.0)
39
+ rubocop-ast (1.3.0)
40
+ parser (>= 2.7.1.5)
41
+ rubocop-minitest (0.10.2)
42
+ rubocop (>= 0.87, < 2.0)
43
+ rubocop-rake (0.5.1)
44
+ rubocop
45
+ ruby-progressbar (1.11.0)
33
46
  simplecov (0.16.1)
34
47
  docile (~> 1.1)
35
48
  json (>= 1.8, < 3)
36
49
  simplecov-html (~> 0.10.0)
37
50
  simplecov-html (0.10.2)
51
+ sync (0.5.0)
38
52
  term-ansicolor (1.7.1)
39
53
  tins (~> 1.0)
40
- thor (0.20.3)
41
- tins (1.20.2)
42
- unicode-display_width (1.6.0)
43
- yard (0.9.19)
54
+ thor (1.0.1)
55
+ tins (1.26.0)
56
+ sync
57
+ unicode-display_width (1.7.0)
58
+ yard (0.9.26)
44
59
 
45
60
  PLATFORMS
46
- ruby
61
+ x86_64-darwin-20
47
62
 
48
63
  DEPENDENCIES
49
64
  coveralls
50
65
  cri!
66
+ m (~> 1.5)
51
67
  minitest
52
68
  rake
53
69
  rubocop
70
+ rubocop-minitest (~> 0.10.2)
71
+ rubocop-rake (~> 0.5.1)
54
72
  yard
55
73
 
56
74
  BUNDLED WITH
57
- 2.0.1
75
+ 2.2.3
data/NEWS.md CHANGED
@@ -1,86 +1,167 @@
1
1
  # Cri News
2
2
 
3
+ ## 2.15.11
4
+
5
+ Fixes:
6
+
7
+ - Added support for Ruby 3.0 (#111)
8
+
9
+ Changes:
10
+
11
+ - Dropped support for Ruby 2.3 and 2.4 (#112)
12
+
13
+ ## 2.15.10
14
+
15
+ Fixes:
16
+
17
+ - Fixed warnings appearing in Ruby 2.7 (9a3d810)
18
+
19
+ ## 2.15.9
20
+
21
+ Fixes:
22
+
23
+ - Fixed bug which could cause options from one command appear in other commands (#101, #102)
24
+
25
+ ## 2.15.8
26
+
27
+ Fixes:
28
+
29
+ - Don’t explicitly set default values for options (#99)
30
+
31
+ This release reverts a backwards-incompatible change introduced in 2.15.7.
32
+
33
+ To illustrate this, compare the behavior of the following command in recent versions of Cri:
34
+
35
+ ```ruby
36
+ option :f, :force, 'use force', argument: :forbidden
37
+
38
+ run do |opts, args, cmd|
39
+ puts "Options = #{opts.inspect}"
40
+ puts "Force? #{opts[:force]}"
41
+ puts "Option given? #{opts.key?(:force)}"
42
+ end
43
+ ```
44
+
45
+ In Cri 2.15.6, the default is not set in the options hash, so the value is `nil` and `#key?` returns false:
46
+
47
+ ```sh
48
+ % ./run
49
+ Options = {}
50
+ Force? nil
51
+ Option given? false
52
+ ```
53
+
54
+ This behavior was inconsistent with what was documented: flag options were (and still are) documented to default to `false` rather than `nil`.
55
+
56
+ In Cri 2.15.7, the default value is `false`, and explicitly set in the options hash (`#key?` returns `true`):
57
+
58
+ ```sh
59
+ % ./run
60
+ Options = {:force=>false}
61
+ Force? false
62
+ Option given? true
63
+ ```
64
+
65
+ This change made it impossible to detect options that were not explicitly specified, because the behavior of `#key?` also changed.
66
+
67
+ In Cri 2.15.8, the default value is also `false` (as in 2.15.7), but not explicitly set in the options hash (`#key?` returns `false`, as in 2.15.6):
68
+
69
+ ```sh
70
+ % ./run
71
+ Options = {}
72
+ Force? false
73
+ Option given? false
74
+ ```
75
+
76
+ This backwards-incompatible change was not intentional. To fix issue #94, a change in behavior was needed, but this change also affected other, previously-undefined behavior. The new behavior in 2.15.8 should fix the bug fixed in 2.15.7 (#94, #96), without causing the problems introduced in that version.
77
+
78
+ ## 2.15.7
79
+
80
+ Fixes:
81
+
82
+ - Options with a forbidden argument now default to false, rather than nil (#94, #96)
83
+
3
84
  ## 2.15.6
4
85
 
5
86
  Fixes:
6
87
 
7
- * Fixed problem with help header not being shown if the summary is missing (#93)
88
+ - Fixed problem with help header not being shown if the summary is missing (#93)
8
89
 
9
90
  ## 2.15.5
10
91
 
11
92
  Fixes:
12
93
 
13
- * Restored compatibility with Ruby 2.3. (#91)
94
+ - Restored compatibility with Ruby 2.3. (#91)
14
95
 
15
96
  ## 2.15.4
16
97
 
17
98
  Fixes:
18
99
 
19
- * Removed dependency on `colored`, which restores functionality to gems that `colored` breaks (e.g. `awesome_print`) (#89, #90)
100
+ - Removed dependency on `colored`, which restores functionality to gems that `colored` breaks (e.g. `awesome_print`) (#89, #90)
20
101
 
21
102
  ## 2.15.3
22
103
 
23
104
  Fixes:
24
105
 
25
- * Made `ArgumentList#each` callable without a block, in which case it returns an `Enumerator` (mimicking `Array`) (#87, #88)
106
+ - Made `ArgumentList#each` callable without a block, in which case it returns an `Enumerator` (mimicking `Array`) (#87, #88)
26
107
 
27
108
  ## 2.15.2
28
109
 
29
110
  Fixes:
30
111
 
31
- * Fixed option propagation for two levels or more (#85, #86)
112
+ - Fixed option propagation for two levels or more (#85, #86)
32
113
 
33
114
  ## 2.15.1
34
115
 
35
116
  Fixes:
36
117
 
37
- * Made -h/--help not fail when parameters are defined for the command that -h/--help is called on (#76, #78)
118
+ - Made -h/--help not fail when parameters are defined for the command that -h/--help is called on (#76, #78)
38
119
 
39
120
  Enhancements:
40
121
 
41
- * Made `#option` raise an error when unrecognised parameters are passed to it (#77) [Marc-André Lafortune]
122
+ - Made `#option` raise an error when unrecognised parameters are passed to it (#77) [Marc-André Lafortune]
42
123
 
43
124
  ## 2.15.0
44
125
 
45
126
  Features:
46
127
 
47
- * Added support for parameter transformation (#72)
128
+ - Added support for parameter transformation (#72)
48
129
 
49
130
  ## 2.14.0
50
131
 
51
132
  Features:
52
133
 
53
- * Added `Cri::Command.load_file`
134
+ - Added `Cri::Command.load_file`
54
135
 
55
136
  ## 2.13.0
56
137
 
57
138
  Features:
58
139
 
59
- * Added support for explicitly specifying zero parameters using `#no_params` (#71)
140
+ - Added support for explicitly specifying zero parameters using `#no_params` (#71)
60
141
 
61
142
  ## 2.12.0
62
143
 
63
144
  Features:
64
145
 
65
- * Added support for parameter naming and validation (#70)
146
+ - Added support for parameter naming and validation (#70)
66
147
 
67
148
  ## 2.11.0
68
149
 
69
150
  Features:
70
151
 
71
- * Added support for transforming option values (#68)
152
+ - Added support for transforming option values (#68)
72
153
 
73
154
  ## 2.10.1
74
155
 
75
156
  Fixes:
76
157
 
77
- * Restored Ruby 2.1 compatibility (for now)
158
+ - Restored Ruby 2.1 compatibility (for now)
78
159
 
79
160
  ## 2.10.0
80
161
 
81
162
  Features:
82
163
 
83
- * Added support for skipping option parsing (#62) [Tim Sharpe]
164
+ - Added support for skipping option parsing (#62) [Tim Sharpe]
84
165
 
85
166
  This release drops support for Ruby 2.1, which is no longer supported.
86
167
 
@@ -88,102 +169,102 @@ This release drops support for Ruby 2.1, which is no longer supported.
88
169
 
89
170
  Fixes:
90
171
 
91
- * Made default values be always returned, even when not explicitly specified (#57, #58)
172
+ - Made default values be always returned, even when not explicitly specified (#57, #58)
92
173
 
93
174
  ## 2.9.0
94
175
 
95
176
  Features:
96
177
 
97
- * Allowed specifying default option value (#55)
178
+ - Allowed specifying default option value (#55)
98
179
 
99
180
  Enhancements:
100
181
 
101
- * Added support for specifying values for combined options (#56)
182
+ - Added support for specifying values for combined options (#56)
102
183
 
103
184
  ## 2.8.0
104
185
 
105
186
  Features:
106
187
 
107
- * Allowed passing `hard_exit: false` to `Command#run` to prevent `SystemExit` (#51)
108
- * Allowed specifying the default subcommand (#54)
188
+ - Allowed passing `hard_exit: false` to `Command#run` to prevent `SystemExit` (#51)
189
+ - Allowed specifying the default subcommand (#54)
109
190
 
110
191
  ## 2.7.1
111
192
 
112
193
  Fixes:
113
194
 
114
- * Fixed some grammatical mistakes
195
+ - Fixed some grammatical mistakes
115
196
 
116
197
  ## 2.7.0
117
198
 
118
199
  Features:
119
200
 
120
- * Added support for hidden options (#43, #44) [Bart Mesuere]
201
+ - Added support for hidden options (#43, #44) [Bart Mesuere]
121
202
 
122
203
  Enhancements:
123
204
 
124
- * Added option values to help output (#37, #40, #41)
125
- * Made option descriptions wrap (#36, #45) [Bart Mesuere]
205
+ - Added option values to help output (#37, #40, #41)
206
+ - Made option descriptions wrap (#36, #45) [Bart Mesuere]
126
207
 
127
208
  ## 2.6.1
128
209
 
129
- * Disable ANSI color codes when not supported (#31, #32)
210
+ - Disable ANSI color codes when not supported (#31, #32)
130
211
 
131
212
  ## 2.6.0
132
213
 
133
- * Added support for multi-valued options (#29) [Toon Willems]
214
+ - Added support for multi-valued options (#29) [Toon Willems]
134
215
 
135
216
  ## 2.5.0
136
217
 
137
- * Made the default help command handle subcommands (#27)
138
- * Added `#raw` method to argument arrays, returning all arguments including `--` (#22)
218
+ - Made the default help command handle subcommands (#27)
219
+ - Added `#raw` method to argument arrays, returning all arguments including `--` (#22)
139
220
 
140
221
  ## 2.4.1
141
222
 
142
- * Fixed ordering of option groups on Ruby 1.8.x (#14, #15)
143
- * Fixed ordering of commands when --verbose is passed (#16, #18)
223
+ - Fixed ordering of option groups on Ruby 1.8.x (#14, #15)
224
+ - Fixed ordering of commands when --verbose is passed (#16, #18)
144
225
 
145
226
  ## 2.4.0
146
227
 
147
- * Allowed either short or long option to be, eh, optional (#9, #10) [Ken Coar]
148
- * Fixed wrap-and-indent behavior (#12) [Ken Coar]
149
- * Moved version information into `cri/version`
228
+ - Allowed either short or long option to be, eh, optional (#9, #10) [Ken Coar]
229
+ - Fixed wrap-and-indent behavior (#12) [Ken Coar]
230
+ - Moved version information into `cri/version`
150
231
 
151
232
  ## 2.3.0
152
233
 
153
- * Added colors (#1)
154
- * Added support for marking commands as hidden
234
+ - Added colors (#1)
235
+ - Added support for marking commands as hidden
155
236
 
156
237
  ## 2.2.1
157
238
 
158
- * Made command help sort subcommands
239
+ - Made command help sort subcommands
159
240
 
160
241
  ## 2.2.0
161
242
 
162
- * Allowed commands with subcommands to have a run block
243
+ - Allowed commands with subcommands to have a run block
163
244
 
164
245
  ## 2.1.0
165
246
 
166
- * Added support for runners
167
- * Split up local/global command options
247
+ - Added support for runners
248
+ - Split up local/global command options
168
249
 
169
250
  ## 2.0.2
170
251
 
171
- * Added command filename to stack traces
252
+ - Added command filename to stack traces
172
253
 
173
254
  ## 2.0.1
174
255
 
175
- * Sorted ambiguous command names
176
- * Restored compatibility with Ruby 1.8.x
256
+ - Sorted ambiguous command names
257
+ - Restored compatibility with Ruby 1.8.x
177
258
 
178
259
  ## 2.0.0
179
260
 
180
- * Added DSL
181
- * Added support for nested commands
261
+ - Added DSL
262
+ - Added support for nested commands
182
263
 
183
264
  ## 1.0.1
184
265
 
185
- * Made gem actually include code. D'oh.
266
+ - Made gem actually include code. D'oh.
186
267
 
187
268
  ## 1.0.0
188
269
 
189
- * Initial release!
270
+ - Initial release!
data/README.md CHANGED
@@ -12,7 +12,14 @@ nested commands.
12
12
 
13
13
  ## Requirements
14
14
 
15
- Cri requires Ruby 2.3 or newer.
15
+ Cri requires Ruby 2.5 or newer (including Ruby 3.x).
16
+
17
+ ## Compatibility policy
18
+
19
+ Cri is guaranteed to be supported on any [officially supported Ruby version](https://www.ruby-lang.org/en/downloads/branches/), as well as the version of Ruby that comes by default on
20
+
21
+ - the last two [Ubuntu LTS releases](https://wiki.ubuntu.com/Releases)
22
+ - the last two major [macOS releases](https://en.wikipedia.org/wiki/MacOS_version_history)
16
23
 
17
24
  ## Usage
18
25
 
@@ -112,101 +119,101 @@ The most generic way of definition an option is using either `#option` or `#opt`
112
119
  2. a long option name
113
120
  3. a description
114
121
  4. optional extra parameters
115
- * `argument:` (default: `:forbidden`)
116
- * `transform:`
117
- * `default:`
118
- * `multiple:` (default: `false`)
122
+ - `argument:` (default: `:forbidden`)
123
+ - `transform:`
124
+ - `default:`
125
+ - `multiple:` (default: `false`)
119
126
  5. optionally, a block
120
127
 
121
128
  In more detail:
122
129
 
123
- * The short option name is a symbol containing one character, to be used in single-dash options, e.g. `:f` (corresponds to `-f`). The long option name is a symbol containing a string, to be used in double-dash options, e.g. `:force` (corresponds to `--force`). Either the short or the long option name can be nil, but not both.
130
+ - The short option name is a symbol containing one character, to be used in single-dash options, e.g. `:f` (corresponds to `-f`). The long option name is a symbol containing a string, to be used in double-dash options, e.g. `:force` (corresponds to `--force`). Either the short or the long option name can be nil, but not both.
124
131
 
125
- * The description is a short, one-line text that shows up in the command’s help. For example, the `-v`/`--version` option might have the description `show version information and quit`.
132
+ - The description is a short, one-line text that shows up in the command’s help. For example, the `-v`/`--version` option might have the description `show version information and quit`.
126
133
 
127
- * The extra parameters, `argument:`, `multiple:`, `default:`, and `transform:`, are described in the sections below.
134
+ - The extra parameters, `argument:`, `multiple:`, `default:`, and `transform:`, are described in the sections below.
128
135
 
129
- * The block, if given, will be executed when the option is found. The arguments to the block are the option value (`true` in case the option does not have an argument) and the command.
136
+ - The block, if given, will be executed when the option is found. The arguments to the block are the option value (`true` in case the option does not have an argument) and the command.
130
137
 
131
138
  There are several convenience methods that are alternatives to `#option`/`#opt`:
132
139
 
133
- * `#flag` sets `argument:` to `:forbidden`
134
- * (**deprecated**) `#required` sets `argument:` to `:required` -- deprecated because `#required` suggests that the option is required, wich is incorrect; the _argument_ is required.)
135
- * (**deprecated**) `#optional` sets `argument:` to `:optional` -- deprecated because `#optional` looks too similar to `#option`.
140
+ - `#flag` sets `argument:` to `:forbidden`
141
+ - (**deprecated**) `#required` sets `argument:` to `:required` -- deprecated because `#required` suggests that the option is required, wich is incorrect; the _argument_ is required.)
142
+ - (**deprecated**) `#optional` sets `argument:` to `:optional` -- deprecated because `#optional` looks too similar to `#option`.
136
143
 
137
144
  #### Forbidden, required, and optional arguments (`argument:`)
138
145
 
139
146
  The `:argument` parameter can be set to `:forbidden`, `:required`, or `:optional`.
140
147
 
141
- * `:forbidden` means that when the option is present, the value will be set to `true`, and `false` otherwise. For example:
148
+ - `:forbidden` means that when the option is present, the value will be set to `true`, and `false` otherwise. For example:
142
149
 
143
- ```ruby
144
- option :f, :force, 'push with force', argument: :forbidden
150
+ ```ruby
151
+ option :f, :force, 'push with force', argument: :forbidden
145
152
 
146
- run do |opts, args, cmd|
147
- puts "Force? #{opts[:force]}"
148
- end
149
- ```
153
+ run do |opts, args, cmd|
154
+ puts "Force? #{opts[:force]}"
155
+ end
156
+ ```
150
157
 
151
- ```sh
152
- % ./push mypackage.zip
153
- Force? false
158
+ ```sh
159
+ % ./push mypackage.zip
160
+ Force? false
154
161
 
155
- % ./push --force mypackage.zip
156
- Force? true
157
- ```
162
+ % ./push --force mypackage.zip
163
+ Force? true
164
+ ```
158
165
 
159
- `:argument` is set to `:forbidden` by default.
166
+ `:argument` is set to `:forbidden` by default.
160
167
 
161
- * `:required` means that the option must be followed by an argument, which will then be treated as the value for the option. It does not mean that the option itself is required. For example:
168
+ - `:required` means that the option must be followed by an argument, which will then be treated as the value for the option. It does not mean that the option itself is required. For example:
162
169
 
163
- ```ruby
164
- option :o, :output, 'specify output file', argument: :required
165
- option :f, :fast, 'fetch faster', argument: :forbidden
170
+ ```ruby
171
+ option :o, :output, 'specify output file', argument: :required
172
+ option :f, :fast, 'fetch faster', argument: :forbidden
166
173
 
167
- run do |opts, args, cmd|
168
- puts "Output file: #{opts[:output]}"
169
- end
170
- ```
174
+ run do |opts, args, cmd|
175
+ puts "Output file: #{opts[:output]}"
176
+ end
177
+ ```
171
178
 
172
- ```sh
173
- % ./fetch http://example.com/source.zip
174
- Output file: nil
179
+ ```sh
180
+ % ./fetch http://example.com/source.zip
181
+ Output file: nil
175
182
 
176
- % ./fetch --output example.zip http://example.com/source.zip
177
- Output file: example.zip
183
+ % ./fetch --output example.zip http://example.com/source.zip
184
+ Output file: example.zip
178
185
 
179
- % ./fetch http://example.com/source.zip --output
180
- fetch: option requires an argument -- output
186
+ % ./fetch http://example.com/source.zip --output
187
+ fetch: option requires an argument -- output
181
188
 
182
- % ./fetch --output --fast http://example.com/source.zip
183
- fetch: option requires an argument -- output
184
- ```
189
+ % ./fetch --output --fast http://example.com/source.zip
190
+ fetch: option requires an argument -- output
191
+ ```
185
192
 
186
- * `:optional` means that the option can be followed by an argument. If it is, then the argument is treated as the value for the option; if it isn’t, the value for the option will be `true`. For example:
193
+ - `:optional` means that the option can be followed by an argument. If it is, then the argument is treated as the value for the option; if it isn’t, the value for the option will be `true`. For example:
187
194
 
188
- ```ruby
189
- option :o, :output, 'specify output file', argument: :optional
190
- option :f, :fast, 'fetch faster', argument: :forbidden
195
+ ```ruby
196
+ option :o, :output, 'specify output file', argument: :optional
197
+ option :f, :fast, 'fetch faster', argument: :forbidden
191
198
 
192
- run do |opts, args, cmd|
193
- puts "Output file: #{opts[:output]}"
194
- end
195
- ```
199
+ run do |opts, args, cmd|
200
+ puts "Output file: #{opts[:output]}"
201
+ end
202
+ ```
196
203
 
197
- ```sh
198
- % ./fetch http://example.com/source.zip
199
- Output file: nil
204
+ ```sh
205
+ % ./fetch http://example.com/source.zip
206
+ Output file: nil
200
207
 
201
- % ./fetch --output example.zip http://example.com/source.zip
202
- Output file: example.zip
208
+ % ./fetch --output example.zip http://example.com/source.zip
209
+ Output file: example.zip
203
210
 
204
- % ./fetch http://example.com/source.zip --output
205
- Output file: true
211
+ % ./fetch http://example.com/source.zip --output
212
+ Output file: true
206
213
 
207
- % ./fetch --output --fast http://example.com/source.zip
208
- Output file: true
209
- ```
214
+ % ./fetch --output --fast http://example.com/source.zip
215
+ Output file: true
216
+ ```
210
217
 
211
218
  #### Transforming options (`transform:`)
212
219
 
@@ -260,6 +267,33 @@ OPTIONS
260
267
  -a --animal[=<value>] add animal (default: giraffe)
261
268
  ```
262
269
 
270
+ If the option is not given on the command line, the `options` hash will not have key for this option, but will still have a default value:
271
+
272
+ ```ruby
273
+ option :a, :animal, 'add animal', default: 'giraffe', argument: :required
274
+
275
+ run do |opts, args, cmd|
276
+ puts "Animal = #{opts[:animal]}"
277
+ puts "Option given? #{opts.key?(:animal)}"
278
+ end
279
+ ```
280
+
281
+ ```sh
282
+ % ./run --animal=donkey
283
+ Animal = donkey
284
+ Option given? true
285
+
286
+ % ./run --animal=giraffe
287
+ Animal = giraffe
288
+ Option given? true
289
+
290
+ % ./run
291
+ Animal = giraffe
292
+ Option given? false
293
+ ```
294
+
295
+ This can be useful to distinguish between an explicitly-passed-in value and a default value. In the example above, the `animal` option is set to `giraffe` in the second and third cases, but it is possible to detect whether the value is a default or not.
296
+
263
297
  #### Multivalued options (`multiple:`)
264
298
 
265
299
  The `:multiple` parameter allows an option to be specified more than once on the command line. When set to `true`, multiple option valus are accepted, and the option values will be stored in an array.
@@ -340,7 +374,7 @@ As with options, parameter definitions take `transform:`, which can be used for
340
374
  param :port, transform: method(:Integer)
341
375
  ```
342
376
 
343
- (*Why the distinction between argument and parameter?* A parameter is a name, e.g. `filename`, while an argument is a value for a parameter, e.g. `kitten.jpg`.)
377
+ (_Why the distinction between argument and parameter?_ A parameter is a name, e.g. `filename`, while an argument is a value for a parameter, e.g. `kitten.jpg`.)
344
378
 
345
379
  ### Allowing arbitrary arguments
346
380
 
@@ -550,10 +584,10 @@ cmd = Cri::Command.load_file('commands/check.rb', infer_name: true)
550
584
 
551
585
  ## Contributors
552
586
 
553
- * Bart Mesuere
554
- * Ken Coar
555
- * Tim Sharpe
556
- * Toon Willems
587
+ - Bart Mesuere
588
+ - Ken Coar
589
+ - Tim Sharpe
590
+ - Toon Willems
557
591
 
558
592
  Thanks for Lee “injekt” Jarvis for [Slop](https://github.com/injekt/slop),
559
593
  which has inspired the design of Cri 2.0.
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.files = Dir['[A-Z]*'] + Dir['{lib,test}/**/*'] + ['cri.gemspec']
17
17
  s.require_paths = ['lib']
18
18
 
19
- s.required_ruby_version = '~> 2.3'
19
+ s.required_ruby_version = '>= 2.5'
20
20
 
21
21
  s.rdoc_options = ['--main', 'README.md']
22
22
  s.extra_rdoc_files = ['LICENSE', 'README.md', 'NEWS.md']
@@ -6,12 +6,7 @@ module Cri
6
6
  # Error that will be raised when an incorrect number of arguments is given.
7
7
  class ArgumentCountMismatchError < Cri::Error
8
8
  def initialize(expected_count, actual_count)
9
- @expected_count = expected_count
10
- @actual_count = actual_count
11
- end
12
-
13
- def message
14
- "incorrect number of arguments given: expected #{@expected_count}, but got #{@actual_count}"
9
+ super("incorrect number of arguments given: expected #{expected_count}, but got #{actual_count}")
15
10
  end
16
11
  end
17
12
 
@@ -46,6 +46,8 @@ module Cri
46
46
  # @api private
47
47
  class CriExitException < StandardError
48
48
  def initialize(is_error:)
49
+ super('exit requested')
50
+
49
51
  @is_error = is_error
50
52
  end
51
53
 
@@ -343,8 +345,9 @@ module Cri
343
345
  explicitly_no_params?,
344
346
  )
345
347
  handle_errors_while { parser.run }
346
- local_opts = parser.options
348
+ local_opts = parser.options
347
349
  global_opts = parent_opts.merge(parser.options)
350
+ global_opts = add_defaults(global_opts)
348
351
 
349
352
  # Handle options
350
353
  handle_options(local_opts)
@@ -359,6 +362,14 @@ module Cri
359
362
  block.call(global_opts, args, self)
360
363
  end
361
364
 
365
+ def all_opt_defns
366
+ if supercommand
367
+ supercommand.all_opt_defns | option_definitions
368
+ else
369
+ option_definitions
370
+ end
371
+ end
372
+
362
373
  # @return [String] The help text for this command
363
374
  #
364
375
  # @option params [Boolean] :verbose true if the help output should be
@@ -366,8 +377,8 @@ module Cri
366
377
  #
367
378
  # @option params [IO] :io ($stdout) the IO the help text is intended for.
368
379
  # This influences the decision to enable/disable colored output.
369
- def help(params = {})
370
- HelpRenderer.new(self, params).render
380
+ def help(**params)
381
+ HelpRenderer.new(self, **params).render
371
382
  end
372
383
 
373
384
  # Compares this command's name to the other given command's name.
@@ -428,5 +439,23 @@ module Cri
428
439
  warn "#{name}: #{e.message}"
429
440
  raise CriExitException.new(is_error: true)
430
441
  end
442
+
443
+ def add_defaults(options)
444
+ all_opt_defns_by_key =
445
+ all_opt_defns.each_with_object({}) do |opt_defn, hash|
446
+ key = (opt_defn.long || opt_defn.short).to_sym
447
+ hash[key] = opt_defn
448
+ end
449
+
450
+ new_options = Hash.new do |hash, key|
451
+ hash.fetch(key) { all_opt_defns_by_key[key]&.default }
452
+ end
453
+
454
+ options.each do |key, value|
455
+ new_options[key] = value
456
+ end
457
+
458
+ new_options
459
+ end
431
460
  end
432
461
  end
@@ -8,12 +8,7 @@ module Cri
8
8
  # already declared as taken no params.
9
9
  class AlreadySpecifiedAsNoParams < Cri::Error
10
10
  def initialize(param, command)
11
- @param = param
12
- @command = command
13
- end
14
-
15
- def message
16
- "Attempted to specify a parameter #{@param.inspect} to the command #{@command.name.inspect}, which is already specified as taking no params. Suggestion: remove the #no_params call."
11
+ super("Attempted to specify a parameter #{param.inspect} to the command #{command.name.inspect}, which is already specified as taking no params. Suggestion: remove the #no_params call.")
17
12
  end
18
13
  end
19
14
 
@@ -21,11 +16,7 @@ module Cri
21
16
  # parameters, when the command is already declared with parameters.
22
17
  class AlreadySpecifiedWithParams < Cri::Error
23
18
  def initialize(command)
24
- @command = command
25
- end
26
-
27
- def message
28
- "Attempted to declare the command #{@command.name.inspect} as taking no parameters, but some parameters are already declared for this command. Suggestion: remove the #no_params call."
19
+ super("Attempted to declare the command #{command.name.inspect} as taking no parameters, but some parameters are already declared for this command. Suggestion: remove the #no_params call.")
29
20
  end
30
21
  end
31
22
 
@@ -215,9 +206,9 @@ module Cri
215
206
  # @deprecated
216
207
  #
217
208
  # @see #option
218
- def required(short, long, desc, params = {}, &block)
209
+ def required(short, long, desc, **params, &block)
219
210
  params = params.merge(argument: :required)
220
- option(short, long, desc, params, &block)
211
+ option(short, long, desc, **params, &block)
221
212
  end
222
213
 
223
214
  # Adds a new option with a forbidden argument to the command. If a block
@@ -238,9 +229,9 @@ module Cri
238
229
  # @return [void]
239
230
  #
240
231
  # @see #option
241
- def flag(short, long, desc, params = {}, &block)
232
+ def flag(short, long, desc, **params, &block)
242
233
  params = params.merge(argument: :forbidden)
243
- option(short, long, desc, params, &block)
234
+ option(short, long, desc, **params, &block)
244
235
  end
245
236
  alias forbidden flag
246
237
 
@@ -264,9 +255,9 @@ module Cri
264
255
  # @deprecated
265
256
  #
266
257
  # @see #option
267
- def optional(short, long, desc, params = {}, &block)
258
+ def optional(short, long, desc, **params, &block)
268
259
  params = params.merge(argument: :optional)
269
- option(short, long, desc, params, &block)
260
+ option(short, long, desc, **params, &block)
270
261
  end
271
262
 
272
263
  # Sets the run block to the given block. The given block should have two
@@ -19,7 +19,7 @@ module Cri
19
19
  #
20
20
  # @option params [Boolean] :verbose true if the help output should be
21
21
  # verbose, false otherwise.
22
- def initialize(cmd, params = {})
22
+ def initialize(cmd, **params)
23
23
  @cmd = cmd
24
24
  @is_verbose = params.fetch(:verbose, false)
25
25
  @io = params.fetch(:io, $stdout)
@@ -13,16 +13,16 @@ module Cri
13
13
  attr_reader :default
14
14
  attr_reader :transform
15
15
 
16
- def initialize(params = {})
17
- @short = params.fetch(:short)
18
- @long = params.fetch(:long)
19
- @desc = params.fetch(:desc)
20
- @argument = params.fetch(:argument)
21
- @multiple = params.fetch(:multiple)
22
- @block = params.fetch(:block)
23
- @hidden = params.fetch(:hidden)
24
- @default = params.fetch(:default)
25
- @transform = params.fetch(:transform)
16
+ def initialize(short:, long:, desc:, argument:, multiple:, block:, hidden:, default:, transform:)
17
+ @short = short
18
+ @long = long
19
+ @desc = desc
20
+ @argument = argument
21
+ @multiple = multiple
22
+ @block = block
23
+ @hidden = hidden
24
+ @default = default
25
+ @transform = transform
26
26
 
27
27
  if @short.nil? && @long.nil?
28
28
  raise ArgumentError, 'short and long options cannot both be nil'
@@ -31,6 +31,8 @@ module Cri
31
31
  if @default && @argument == :forbidden
32
32
  raise ArgumentError, 'a default value cannot be specified for flag options'
33
33
  end
34
+
35
+ @default = false if @argument == :forbidden
34
36
  end
35
37
 
36
38
  def to_h
@@ -14,12 +14,10 @@ module Cri
14
14
  attr_reader :value
15
15
 
16
16
  def initialize(definition, value)
17
- @definition = definition
18
- @value = value
19
- end
17
+ super("invalid value #{value.inspect} for #{definition.formatted_name} option")
20
18
 
21
- def message
22
- "invalid value #{value.inspect} for #{@definition.formatted_name} option"
19
+ @value = value
20
+ @definition = definition
23
21
  end
24
22
  end
25
23
 
@@ -118,8 +116,6 @@ module Cri
118
116
  end
119
117
  end
120
118
 
121
- add_defaults
122
-
123
119
  self
124
120
  ensure
125
121
  @running = false
@@ -133,10 +129,6 @@ module Cri
133
129
 
134
130
  private
135
131
 
136
- def add_defaults
137
- @option_defns.each { |d| add_default_option(d) }
138
- end
139
-
140
132
  def handle_dashdash(elem)
141
133
  add_argument(elem)
142
134
  @no_more_options = true
@@ -223,16 +215,6 @@ module Cri
223
215
  delegate&.option_added(key, value, self)
224
216
  end
225
217
 
226
- def add_default_option(option_defn)
227
- key = key_for(option_defn)
228
- return if options.key?(key)
229
-
230
- value = option_defn.default
231
- return unless value
232
-
233
- add_option(option_defn, value, transform: false)
234
- end
235
-
236
218
  def transform_value(option_defn, value)
237
219
  transformer = option_defn.transform
238
220
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Cri
4
4
  # The current Cri version.
5
- VERSION = '2.15.6'
5
+ VERSION = '2.15.11'
6
6
  end
@@ -549,7 +549,7 @@ module Cri
549
549
  end
550
550
 
551
551
  def test_hidden_commands_multiple
552
- cmd = nested_cmd
552
+ cmd = nested_cmd
553
553
 
554
554
  subcmd = simple_cmd
555
555
  cmd.add_command subcmd
@@ -895,5 +895,110 @@ module Cri
895
895
  assert_equal ['test? true!'], lines(out)
896
896
  assert_equal [], lines(err)
897
897
  end
898
+
899
+ def test_flag_defaults_to_false
900
+ cmd = Cri::Command.define do
901
+ name 'a'
902
+ option :f, :force2, 'push with force', argument: :forbidden
903
+
904
+ run do |opts, _args, _cmd|
905
+ puts "Force? #{opts[:force2].inspect}! Key present? #{opts.key?(:force2)}!"
906
+ end
907
+ end
908
+
909
+ out, err = capture_io_while do
910
+ cmd.run(%w[])
911
+ end
912
+ assert_equal ['Force? false! Key present? false!'], lines(out)
913
+ assert_equal [], lines(err)
914
+ end
915
+
916
+ def test_required_option_defaults_to_given_value
917
+ cmd = Cri::Command.define do
918
+ name 'a'
919
+ option :a, :animal, 'specify animal', argument: :required, default: 'cow'
920
+
921
+ run do |opts, _args, _cmd|
922
+ puts "Animal = #{opts[:animal]}! Key present? #{opts.key?(:animal)}!"
923
+ end
924
+ end
925
+
926
+ out, err = capture_io_while do
927
+ cmd.run(%w[])
928
+ end
929
+ assert_equal ['Animal = cow! Key present? false!'], lines(out)
930
+ assert_equal [], lines(err)
931
+ end
932
+
933
+ def test_optional_option_defaults_to_given_value
934
+ cmd = Cri::Command.define do
935
+ name 'a'
936
+ option :a, :animal, 'specify animal', argument: :optional, default: 'cow'
937
+
938
+ run do |opts, _args, _cmd|
939
+ puts "Animal = #{opts[:animal]}"
940
+ end
941
+ end
942
+
943
+ out, err = capture_io_while do
944
+ cmd.run(%w[])
945
+ end
946
+ assert_equal ['Animal = cow'], lines(out)
947
+ assert_equal [], lines(err)
948
+ end
949
+
950
+ def test_required_option_defaults_to_given_value_with_transform
951
+ cmd = Cri::Command.define do
952
+ name 'a'
953
+ option :a, :animal, 'specify animal', argument: :required, transform: ->(a) { a.upcase }, default: 'cow'
954
+
955
+ run do |opts, _args, _cmd|
956
+ puts "Animal = #{opts[:animal]}"
957
+ end
958
+ end
959
+
960
+ out, err = capture_io_while do
961
+ cmd.run(%w[])
962
+ end
963
+ assert_equal ['Animal = cow'], lines(out)
964
+ assert_equal [], lines(err)
965
+ end
966
+
967
+ def test_option_definitions_are_not_shared_across_commands
968
+ root_cmd = Cri::Command.define do
969
+ name 'root'
970
+ option :r, :rrr, 'Rrr!', argument: :required
971
+ end
972
+
973
+ subcmd_a = root_cmd.define_command do
974
+ name 'a'
975
+ option :a, :aaa, 'Aaa!', argument: :required
976
+
977
+ run do |_opts, _args, cmd|
978
+ puts cmd.all_opt_defns.map(&:long).sort.join(',')
979
+ end
980
+ end
981
+
982
+ subcmd_b = root_cmd.define_command do
983
+ name 'b'
984
+ option :b, :bbb, 'Bbb!', argument: :required
985
+
986
+ run do |_opts, _args, cmd|
987
+ puts cmd.all_opt_defns.map(&:long).sort.join(',')
988
+ end
989
+ end
990
+
991
+ out, err = capture_io_while do
992
+ subcmd_a.run(%w[])
993
+ end
994
+ assert_equal ['aaa,rrr'], lines(out)
995
+ assert_equal [], lines(err)
996
+
997
+ out, err = capture_io_while do
998
+ subcmd_b.run(%w[])
999
+ end
1000
+ assert_equal ['bbb,rrr'], lines(out)
1001
+ assert_equal [], lines(err)
1002
+ end
898
1003
  end
899
1004
  end
@@ -41,12 +41,12 @@ module Cri
41
41
  expected_option_definitions =
42
42
  Set.new(
43
43
  [
44
- { short: 'a', long: 'aaa', desc: 'opt a', argument: :optional, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
45
- { short: 'b', long: 'bbb', desc: 'opt b', argument: :required, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
46
- { short: 'c', long: 'ccc', desc: 'opt c', argument: :optional, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
47
- { short: 'd', long: 'ddd', desc: 'opt d', argument: :forbidden, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
48
- { short: 'e', long: 'eee', desc: 'opt e', argument: :forbidden, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
49
- { short: 'f', long: 'fff', desc: 'opt f', argument: :forbidden, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
44
+ { short: 'a', long: 'aaa', desc: 'opt a', argument: :optional, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
45
+ { short: 'b', long: 'bbb', desc: 'opt b', argument: :required, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
46
+ { short: 'c', long: 'ccc', desc: 'opt c', argument: :optional, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
47
+ { short: 'd', long: 'ddd', desc: 'opt d', argument: :forbidden, multiple: false, hidden: false, block: nil, default: false, transform: nil },
48
+ { short: 'e', long: 'eee', desc: 'opt e', argument: :forbidden, multiple: false, hidden: false, block: nil, default: false, transform: nil },
49
+ { short: 'f', long: 'fff', desc: 'opt f', argument: :forbidden, multiple: false, hidden: true, block: nil, default: false, transform: nil },
50
50
  ],
51
51
  )
52
52
  actual_option_definitions = Set.new(command.option_definitions.map(&:to_h))
@@ -80,8 +80,8 @@ module Cri
80
80
  expected_option_definitions =
81
81
  Set.new(
82
82
  [
83
- { short: 's', long: nil, desc: 'short', argument: :forbidden, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
84
- { short: nil, long: 'long', desc: 'long', argument: :forbidden, multiple: false, hidden: false, block: nil, default: nil, transform: nil },
83
+ { short: 's', long: nil, desc: 'short', argument: :forbidden, multiple: false, hidden: false, block: nil, default: false, transform: nil },
84
+ { short: nil, long: 'long', desc: 'long', argument: :forbidden, multiple: false, hidden: false, block: nil, default: false, transform: nil },
85
85
  ],
86
86
  )
87
87
  actual_option_definitions = Set.new(command.option_definitions.map(&:to_h))
@@ -104,9 +104,9 @@ module Cri
104
104
  expected_option_definitions =
105
105
  Set.new(
106
106
  [
107
- { short: 'f', long: 'flag', desc: 'flag', argument: :forbidden, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
108
- { short: 'r', long: 'required', desc: 'req', argument: :required, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
109
- { short: 'o', long: 'optional', desc: 'opt', argument: :optional, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
107
+ { short: 'f', long: 'flag', desc: 'flag', argument: :forbidden, multiple: true, hidden: false, block: nil, default: false, transform: nil },
108
+ { short: 'r', long: 'required', desc: 'req', argument: :required, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
109
+ { short: 'o', long: 'optional', desc: 'opt', argument: :optional, multiple: true, hidden: false, block: nil, default: nil, transform: nil },
110
110
  ],
111
111
  )
112
112
  actual_option_definitions = Set.new(command.option_definitions.map(&:to_h))
@@ -129,9 +129,9 @@ module Cri
129
129
  expected_option_definitions =
130
130
  Set.new(
131
131
  [
132
- { short: 'f', long: 'flag', desc: 'flag', argument: :forbidden, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
133
- { short: 'r', long: 'required', desc: 'req', argument: :required, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
134
- { short: 'o', long: 'optional', desc: 'opt', argument: :optional, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
132
+ { short: 'f', long: 'flag', desc: 'flag', argument: :forbidden, multiple: false, hidden: true, block: nil, default: false, transform: nil },
133
+ { short: 'r', long: 'required', desc: 'req', argument: :required, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
134
+ { short: 'o', long: 'optional', desc: 'opt', argument: :optional, multiple: false, hidden: true, block: nil, default: nil, transform: nil },
135
135
  ],
136
136
  )
137
137
  actual_option_definitions = Set.new(command.option_definitions.map(&:to_h))
@@ -284,18 +284,6 @@ module Cri
284
284
  assert_equal(3, parser.options[:verbose].size)
285
285
  end
286
286
 
287
- def test_parse_with_default_required_unspecified
288
- input = %w[foo]
289
- opt_defns = [
290
- { long: 'animal', short: 'a', argument: :required, default: 'donkey' },
291
- ].map { |hash| make_opt_defn(hash) }
292
-
293
- parser = Cri::Parser.new(input, opt_defns, [], false).run
294
-
295
- assert_equal({ animal: 'donkey' }, parser.options)
296
- assert_equal(['foo'], parser.gen_argument_list.to_a)
297
- end
298
-
299
287
  def test_parse_with_default_required_no_value
300
288
  input = %w[foo -a]
301
289
  opt_defns = [
@@ -319,18 +307,6 @@ module Cri
319
307
  assert_equal(['foo'], parser.gen_argument_list.to_a)
320
308
  end
321
309
 
322
- def test_parse_with_default_optional_unspecified
323
- input = %w[foo]
324
- opt_defns = [
325
- { long: 'animal', short: 'a', argument: :optional, default: 'donkey' },
326
- ].map { |hash| make_opt_defn(hash) }
327
-
328
- parser = Cri::Parser.new(input, opt_defns, [], false).run
329
-
330
- assert_equal({ animal: 'donkey' }, parser.options)
331
- assert_equal(['foo'], parser.gen_argument_list.to_a)
332
- end
333
-
334
310
  def test_parse_with_default_optional_no_value
335
311
  input = %w[foo -a]
336
312
  opt_defns = [
@@ -451,26 +427,6 @@ module Cri
451
427
  assert_equal([], parser.gen_argument_list.to_a)
452
428
  end
453
429
 
454
- def test_parse_with_transform_default
455
- port = Class.new do
456
- def call(str)
457
- raise unless str.is_a?(String)
458
-
459
- Integer(str)
460
- end
461
- end.new
462
-
463
- input = %w[]
464
- opt_defns = [
465
- { long: 'port', short: 'p', argument: :required, default: 8080, transform: port },
466
- ].map { |hash| make_opt_defn(hash) }
467
-
468
- parser = Cri::Parser.new(input, opt_defns, [], false).run
469
-
470
- assert_equal({ port: 8080 }, parser.options)
471
- assert_equal([], parser.gen_argument_list.to_a)
472
- end
473
-
474
430
  def test_parse_with_transform_exception
475
431
  input = %w[--port one_hundred_and_twenty_three]
476
432
  opt_defns = [
@@ -487,7 +443,7 @@ module Cri
487
443
  input = %w[localhost]
488
444
  param_defns = [
489
445
  { name: 'host', transform: nil },
490
- ].map { |hash| Cri::ParamDefinition.new(hash) }
446
+ ].map { |hash| Cri::ParamDefinition.new(**hash) }
491
447
 
492
448
  parser = Cri::Parser.new(input, [], param_defns, false).run
493
449
  assert_equal({}, parser.options)
@@ -499,7 +455,7 @@ module Cri
499
455
  input = []
500
456
  param_defns = [
501
457
  { name: 'host', transform: nil },
502
- ].map { |hash| Cri::ParamDefinition.new(hash) }
458
+ ].map { |hash| Cri::ParamDefinition.new(**hash) }
503
459
 
504
460
  parser = Cri::Parser.new(input, [], param_defns, false).run
505
461
  exception = assert_raises(Cri::ArgumentList::ArgumentCountMismatchError) do
@@ -512,7 +468,7 @@ module Cri
512
468
  input = %w[localhost oink]
513
469
  param_defns = [
514
470
  { name: 'host', transform: nil },
515
- ].map { |hash| Cri::ParamDefinition.new(hash) }
471
+ ].map { |hash| Cri::ParamDefinition.new(**hash) }
516
472
 
517
473
  parser = Cri::Parser.new(input, [], param_defns, false).run
518
474
  exception = assert_raises(Cri::ArgumentList::ArgumentCountMismatchError) do
@@ -525,7 +481,7 @@ module Cri
525
481
  input = %w[localhost]
526
482
  param_defns = [
527
483
  { name: 'host', transform: nil },
528
- ].map { |hash| Cri::ParamDefinition.new(hash) }
484
+ ].map { |hash| Cri::ParamDefinition.new(**hash) }
529
485
 
530
486
  parser = Cri::Parser.new(input, [], param_defns, false).run
531
487
 
@@ -540,7 +496,7 @@ module Cri
540
496
  param_defns = [
541
497
  { name: 'source', transform: nil },
542
498
  { name: 'target', transform: nil },
543
- ].map { |hash| Cri::ParamDefinition.new(hash) }
499
+ ].map { |hash| Cri::ParamDefinition.new(**hash) }
544
500
 
545
501
  parser = Cri::Parser.new(input, [], param_defns, false).run
546
502
  assert_equal({}, parser.options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cri
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.6
4
+ version: 2.15.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-19 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cri allows building easy-to-use command-line interfaces with support
14
14
  for subcommands.
@@ -57,7 +57,7 @@ homepage: https://github.com/ddfreyne/cri
57
57
  licenses:
58
58
  - MIT
59
59
  metadata: {}
60
- post_install_message:
60
+ post_install_message:
61
61
  rdoc_options:
62
62
  - "--main"
63
63
  - README.md
@@ -65,17 +65,17 @@ require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: '2.3'
70
+ version: '2.5'
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.0.3
78
- signing_key:
77
+ rubygems_version: 3.2.3
78
+ signing_key:
79
79
  specification_version: 4
80
80
  summary: a library for building easy-to-use command-line tools
81
81
  test_files: []