cl 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: d68ba1674ee398202a474abb83387fb296847aad
4
- data.tar.gz: 3f410b5991158c25bc3ec7688fd9a86c56b7e11f
3
+ metadata.gz: 95105c27487a964f369771303967d5d2be384e8d
4
+ data.tar.gz: 400c2ed33af51c48e0e3375e165e1c4ff2b25e8e
5
5
  SHA512:
6
- metadata.gz: 26fac7251c6eead9ed449d3f5c1dfb61794eb1f6c7e008f069ac973afd912d84d93b75abaa84ca20f6f69d6642cc00694be28469b36ce8ce0a1f3d044ecb9c3d
7
- data.tar.gz: 993d729a5b9fd4ae131d257601a93b57483ac6f6ba12e46409cffeda230e2a8573b1b9c22edc93392e6c7224de94f979962479fdb23d4b27df32796d84e2b685
6
+ metadata.gz: 3ab78eec6052ea36c538ba031ff5b386bee83a0155d69435b2f85a1e4ff6c3277a284833dddb93d959e267b0a381c62a5b68686220964487c502caefd0c5971d
7
+ data.tar.gz: 2000822998fa8f6d2b1ffccb49cd806b608bed3f73931835b04d47aa3afc08bac4f28c7859dec4a76eeb7ded0f954e29439f3c7c6ce5cdf502cb8fb3a53c2893
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.x
3
+ ## 1.0.1 (2019-08-11)
4
+
5
+ ### Added
6
+
7
+ * Add `opt '--one STR', upcase: true`
8
+
9
+ ## 1.0.0 (2019-08-10)
4
10
 
5
11
  ### Added
6
12
 
@@ -19,7 +25,6 @@
19
25
  * Add `opt '--one STR', format: /.+/`
20
26
  * Add `opt '--one STR', enum: ['one', /\w+/]`
21
27
  * Add `opt '--one STR', downcase: true`
22
- * Add `opt '--one STR', upcase: true`
23
28
  * Add `opt '--one STR', internal: true`, hide internal options from help output
24
29
  * Add `opt '--one STR', example: 'foo'`
25
30
  * Add `opt '--one STR', negate: %w(skip)`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl (1.0.0)
4
+ cl (1.0.1)
5
5
  regstry (~> 1.0.3)
6
6
 
7
7
  GEM
data/lib/cl/dsl.rb CHANGED
@@ -102,6 +102,7 @@ class Cl
102
102
  # @option opts [Object] :default default value for the option
103
103
  # @option opts [String or Symbol] :deprecated deprecation message for the option, or if given a Symbol, deprecated alias name
104
104
  # @option opts [Boolean] :downcase whether to downcase the option value
105
+ # @option opts [Boolean] :upcase whether to upcase the option value
105
106
  # @option opts [Array<Object>] :enum list of acceptable option values
106
107
  # @option opts [String] :example example(s) for the option, shown in help output
107
108
  # @option opts [Regexp] :format acceptable option value format
data/lib/cl/opts.rb CHANGED
@@ -17,13 +17,14 @@ class Cl
17
17
 
18
18
  def apply(cmd, opts)
19
19
  return opts if opts[:help]
20
+ orig = opts.dup
20
21
  cmd.deprecations = deprecations(cmd, opts)
21
- opts = with_defaults(cmd, opts)
22
+ opts = defaults(cmd, opts)
22
23
  opts = downcase(opts)
23
24
  opts = upcase(opts)
24
25
  opts = cast(opts)
25
26
  opts = taint(opts)
26
- validate(cmd, self, opts)
27
+ validate(cmd, self, opts, orig)
27
28
  opts
28
29
  end
29
30
 
@@ -71,7 +72,7 @@ class Cl
71
72
  defs.map(&:deprecated).to_h
72
73
  end
73
74
 
74
- def with_defaults(cmd, opts)
75
+ def defaults(cmd, opts)
75
76
  select(&:default?).inject(opts) do |opts, opt|
76
77
  next opts if opts.key?(opt.name)
77
78
  value = opt.default
@@ -3,15 +3,15 @@ require 'cl/helper'
3
3
  class Cl
4
4
  class Opts
5
5
  module Validate
6
- def validate(cmd, opts, values)
6
+ def validate(cmd, opts, values, orig)
7
7
  Validate.constants.each do |name|
8
8
  next if name == :Validator
9
9
  const = Validate.const_get(name)
10
- const.new(cmd, opts, values).apply
10
+ const.new(cmd, opts, values, orig).apply
11
11
  end
12
12
  end
13
13
 
14
- class Validator < Struct.new(:cmd, :opts, :values)
14
+ class Validator < Struct.new(:cmd, :opts, :values, :orig)
15
15
  include Regex
16
16
  def compact(hash, *keys)
17
17
  hash.reject { |_, value| value.nil? }.to_h
@@ -62,7 +62,7 @@ class Cl
62
62
  end
63
63
 
64
64
  def requires
65
- opts.select(&:requires?).select { |opt| values.key?(opt.name) }
65
+ opts.select(&:requires?).select { |opt| orig.key?(opt.name) }
66
66
  end
67
67
  end
68
68
 
data/lib/cl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Cl
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-10 00:00:00.000000000 Z
11
+ date: 2019-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regstry