opt_parse_validator 1.9.0 → 1.9.1
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/lib/opt_parse_validator.rb +11 -13
- data/lib/opt_parse_validator/opts/base.rb +2 -2
- data/lib/opt_parse_validator/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ccb947d9079bcc004e16bdfea47a5e5207c26e871da1a1cf0c01f2bbeca5b65
|
4
|
+
data.tar.gz: 87139c6bbe1664ff3c70374a81d3e6940193b5d46cd0d07c5905cc22ab468cfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd7dd0aa734ad3ad63bd1644b8ab05213d96a0d3c223de20d2152581c22c04b7f68df65ea52fbe4b189e46d44b32d005b855da92e12c5e336b31eb42553d5c00
|
7
|
+
data.tar.gz: 50bca2d9e0f17c6c1f9662b3d3e6a9d9b1d8ed5352b6e35c4847ac373ff91b64a50adfe53ffd73f993575e90a9cae67cfe7bcd52fafe702cefb30ec44d718dce
|
data/lib/opt_parse_validator.rb
CHANGED
@@ -108,18 +108,16 @@ module OptParseValidator
|
|
108
108
|
# @return [ void ]
|
109
109
|
def register_callback(opt)
|
110
110
|
on(*opt.option) do |arg|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
@results[opt.to_sym] = opt.normalize(opt.validate(arg))
|
116
|
-
end
|
117
|
-
rescue StandardError => e
|
118
|
-
# Adds the long option name to the message
|
119
|
-
# And raises it as an OptParseValidator::Error if not already one
|
120
|
-
# e.g --proxy Invalid Scheme format.
|
121
|
-
raise e.is_a?(Error) ? e.class : Error, "#{opt.to_long} #{e}"
|
111
|
+
if opt.alias?
|
112
|
+
parse!(opt.alias_for.split(' '))
|
113
|
+
else
|
114
|
+
@results[opt.to_sym] = opt.normalize(opt.validate(arg))
|
122
115
|
end
|
116
|
+
rescue StandardError => e
|
117
|
+
# Adds the long option name to the message
|
118
|
+
# And raises it as an OptParseValidator::Error if not already one
|
119
|
+
# e.g --proxy Invalid Scheme format.
|
120
|
+
raise e.is_a?(Error) ? e.class : Error, "#{opt.to_long} #{e}"
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
@@ -147,11 +145,11 @@ module OptParseValidator
|
|
147
145
|
# @return [ Void ]
|
148
146
|
def post_processing
|
149
147
|
@opts.each do |opt|
|
150
|
-
raise NoRequiredOption, "The option
|
148
|
+
raise NoRequiredOption, "The option --#{opt} is required" if opt.required? && !@results.key?(opt.to_sym)
|
151
149
|
|
152
150
|
next if opt.required_unless.empty? || @results.key?(opt.to_sym)
|
153
151
|
|
154
|
-
fail_msg = "One of the following options is required:
|
152
|
+
fail_msg = "One of the following options is required: --#{opt}, --#{opt.required_unless.join(', --')}"
|
155
153
|
|
156
154
|
raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
|
157
155
|
@results.key?(sym)
|
@@ -107,7 +107,7 @@ module OptParseValidator
|
|
107
107
|
|
108
108
|
raise Error, "Could not find option symbol for #{option}" unless long_option
|
109
109
|
|
110
|
-
@symbol = long_option.
|
110
|
+
@symbol = long_option.delete_prefix('--').tr('-', '_').to_sym
|
111
111
|
end
|
112
112
|
@symbol
|
113
113
|
end
|
@@ -115,7 +115,7 @@ module OptParseValidator
|
|
115
115
|
# @return [ String ] The raw long option (e.g: --proxy)
|
116
116
|
def to_long
|
117
117
|
option.each do |option_attr|
|
118
|
-
if
|
118
|
+
if option_attr.start_with?('--')
|
119
119
|
return option_attr.gsub(/ .*$/, '')
|
120
120
|
.gsub(/\[[^\]]+\]/, '')
|
121
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opt_parse_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WPScanTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,28 +112,28 @@ dependencies:
|
|
112
112
|
requirements:
|
113
113
|
- - "~>"
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.
|
115
|
+
version: 0.84.0
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.
|
122
|
+
version: 0.84.0
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
124
|
name: rubocop-performance
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 1.
|
129
|
+
version: 1.6.0
|
130
130
|
type: :development
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
134
|
- - "~>"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: 1.
|
136
|
+
version: 1.6.0
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: simplecov
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|