shellopts 2.0.13 → 2.0.14

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: 8dd7a731b489dbf650e15549d9768469ae9d6c47c6dba3ae79f4d956fea069ab
4
- data.tar.gz: 4b71aff7ba350d4616a136580857a6acd840141ed0b7463034518dcf4ae4dada
3
+ metadata.gz: 2101f633ad0e166982b108842a83f91b3d216869f9fe3d6ac7ecea5256f2b437
4
+ data.tar.gz: da77f695902e5e921e598dd8d1327af4ce07ffe7b9cfadb88fe1b0889b95b4e0
5
5
  SHA512:
6
- metadata.gz: bb5792606dd91f46b95fe786b509fd079697c87fd603c667e49740b365cafafa0cdc7b49a0a86c72cd014f9c2d88cdf74f096422e6099403042d8c34d35044b3
7
- data.tar.gz: d7f2637649b474741b70dd9334e25107586fe52eb4e4f9a289453699f334488fed60322a676ad20fcab2f0c993785ccdef89be4397055028e75d79795766b972
6
+ metadata.gz: 36dbd8d33d74a5b985463df5fb514501c2881881bdd68f1fa479c7ecac3de2bc4a2bc3a713acfe735d3e53ccdde10f5abf5ecc066d370fa8e795a77e290f9988
7
+ data.tar.gz: b364c8d00de2f7ece58d3c721ef3d4f40a892a232aa39a0c94df2b7ef37cf86e78c99df25c07e8802b0e48640ec928c4157bd89a2cb0851955484ed5957733ca
data/TODO CHANGED
@@ -1,4 +1,24 @@
1
1
 
2
+ o In the following list is a command with a mandatory sub-command
3
+
4
+ list.tables!
5
+ list.uuids!
6
+
7
+ It should be rendered as
8
+ list tables|uuids
9
+
10
+ and not as
11
+ list tables
12
+ list uuids
13
+
14
+ and not as
15
+ list [tables|uuids]
16
+
17
+
18
+ o Replace -h with -? when -h is specified by the user (eg. as a shorthand for --host)
19
+ o Limit text width to -10 chars of what it is today (same as stackexchange width in characters)
20
+ o Fix formatting error in long arguments (see ms2pg)
21
+ o Macro that can be used in the SPEC for the program name (eg. <PROGRAM>)
2
22
  o Ignore all text after ' # ' (doesn't conflict with option flag)
3
23
  o Command aliases
4
24
  o Add user-defined setions
@@ -194,33 +194,36 @@ module ShellOpts
194
194
 
195
195
  def __define_option_methods__
196
196
  @__grammar__.options.each { |opt|
197
- if opt.argument? || opt.repeatable?
198
- if opt.optional?
199
- self.instance_eval %(
200
- def #{opt.attr}(default = nil)
201
- if @__option_values__.key?(:#{opt.attr})
202
- @__option_values__[:#{opt.attr}]
203
- else
204
- default
205
- end
197
+ if opt.argument?
198
+ self.instance_eval %(
199
+ def #{opt.attr}(default = nil)
200
+ if @__option_values__.key?(:#{opt.attr})
201
+ @__option_values__[:#{opt.attr}]
202
+ else
203
+ default
206
204
  end
207
- )
208
- elsif !opt.argument? # Repeatable w/o argument
209
- self.instance_eval %(
210
- def #{opt.attr}(default = [])
211
- if @__option_values__.key?(:#{opt.attr})
212
- @__option_values__[:#{opt.attr}]
213
- else
214
- default
215
- end
205
+ end
206
+ )
207
+
208
+ elsif opt.repeatable?
209
+ self.instance_eval %(
210
+ def #{opt.attr}(default = 0)
211
+ if default > 0 && @__option_values__[:#{opt.attr}] == 0
212
+ default
213
+ else
214
+ @__option_values__[:#{opt.attr}]
216
215
  end
217
- )
218
- else
219
- self.instance_eval("def #{opt.attr}() @__option_values__[:#{opt.attr}] end")
220
- end
216
+ end
217
+ )
218
+ else
219
+ self.instance_eval("def #{opt.attr}() @__option_values__[:#{opt.attr}] end")
220
+ end
221
+
222
+ if opt.argument? || opt.repeatable?
221
223
  self.instance_eval("def #{opt.attr}=(value) @__option_values__[:#{opt.attr}] = value end")
222
224
  @__option_values__[opt.attr] = 0 if !opt.argument?
223
225
  end
226
+
224
227
  self.instance_eval("def #{opt.attr}?() @__option_values__.key?(:#{opt.attr}) end")
225
228
  }
226
229
 
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.13"
2
+ VERSION = "2.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-03 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forward_to