cl 1.0.1 → 1.0.2
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 +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +1 -1
- data/lib/cl/dsl.rb +1 -0
- data/lib/cl/opts.rb +4 -3
- data/lib/cl/opts/validate.rb +4 -4
- data/lib/cl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95105c27487a964f369771303967d5d2be384e8d
|
4
|
+
data.tar.gz: 400c2ed33af51c48e0e3375e165e1c4ff2b25e8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
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 =
|
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
|
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
|
data/lib/cl/opts/validate.rb
CHANGED
@@ -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|
|
65
|
+
opts.select(&:requires?).select { |opt| orig.key?(opt.name) }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
data/lib/cl/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: regstry
|