command_kit 0.5.3 → 0.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 451095b9c9d71806fd4d49247e733f44aaa1f167d30a7ab76992f55c589cc6c1
4
- data.tar.gz: bfd419a0c92961eadc07978dec3d136bd9c8375981aa50fd6b0ea855c2c150e3
3
+ metadata.gz: 1a99a41f5bf2442e5523f9f7019dcd6b916f1b645786eefa9b0fb2a84aadd28c
4
+ data.tar.gz: 3fb73eaa7b3a5730baafd0d0bd02cc567e82020acc96dec6a87bf726666f4250
5
5
  SHA512:
6
- metadata.gz: 123a22e7e3cba24445153008600a52fcfc138f10f2a82251e8a712dd9313e53363d2de4be865aa53b5777b75dc4eec2e00f95da1721f9733d2c09f4165161aef
7
- data.tar.gz: 854ac314927a60b2d667555f0f20ffbdd66ac10badbdac81486cb65dc38b2ac2a50d7b52c87a739885cb7058dafa10b969b49cd23aa4e616650d5def428a6194
6
+ metadata.gz: 44673dd7cb91fe176210e319c4055010c4e81af5dabf7eb420b202c1d42637e4844a1f5c99e0d81eeb52d32bfe9221de843b86c8d1f7fc91cc4aece561b46402
7
+ data.tar.gz: 2470a9c111f829fc858c03f8b9be2726028d59da449bd68f778f7d87dc3f6bd93051ad4339ea896fa15f81dbcba3fe06af0b3b1b72f4705108a6cbab5157cba1
data/ChangeLog.md CHANGED
@@ -1,3 +1,23 @@
1
+ ### 0.5.5 / 2024-04-08
2
+
3
+ #### CommandKit::Interactive
4
+
5
+ * Ensure that the interactive prompt is re-printed when no input is entered
6
+ and input is required from the user.
7
+
8
+ #### CommandKit::Options
9
+
10
+ * Do not pass an Array of Regexp captures for an option's value Regexp type
11
+ into an option's block, if the option's block only accepts one argument.
12
+ Instead, only pass the option's value as a String.
13
+
14
+ ### 0.5.4 / 2024-03-14
15
+
16
+ #### CommandKit::Options
17
+
18
+ * Fixed a bug where `Array` option values were only setting the option's value
19
+ to the first element of the parsed `Array` value.
20
+
1
21
  ### 0.5.3 / 2024-03-12
2
22
 
3
23
  #### CommandKit::Interactive
@@ -74,9 +74,9 @@ module CommandKit
74
74
  prompt << " [#{default}]" if default
75
75
  prompt << ": "
76
76
 
77
- stdout.print(prompt)
78
-
79
77
  loop do
78
+ stdout.print(prompt)
79
+
80
80
  value = stdin.gets(chomp: true)
81
81
  value ||= '' # convert nil values (ctrl^D) to an empty String
82
82
 
@@ -302,17 +302,21 @@ module CommandKit
302
302
  # @param [Option] option
303
303
  #
304
304
  def define_option(option)
305
- default_value = option.default_value
306
-
307
- @options[option.name] = default_value unless default_value.nil?
308
-
309
- option_parser.on(*option.usage,option.type,*option.desc) do |arg,*captures|
310
- @options[option.name] = arg
305
+ unless (default_value = option.default_value).nil?
306
+ @options[option.name] = default_value
307
+ end
311
308
 
312
- if option.block
313
- instance_exec(*arg,*captures,&option.block)
309
+ option_parser.on(*option.usage,option.type,*option.desc) do |value|
310
+ if option.type.is_a?(Regexp) && value.is_a?(Array)
311
+ # separate the optiona value from the additional Regexp captures
312
+ value, *args = value
313
+ else
314
+ args = nil
314
315
  end
315
- end
316
+
317
+ @options[option.name] = value
318
+ instance_exec(value,*args,&option.block) if option.block
319
+ end
316
320
  end
317
321
  end
318
322
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CommandKit
4
4
  # command_kit version
5
- VERSION = "0.5.3"
5
+ VERSION = "0.5.5"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler