opt_parse_validator 0.0.13.8 → 0.0.13.9
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/README.md +10 -1
- data/lib/opt_parse_validator/opts.rb +1 -0
- data/lib/opt_parse_validator/opts/array.rb +2 -0
- data/lib/opt_parse_validator/opts/base.rb +7 -2
- data/lib/opt_parse_validator/opts/choice.rb +2 -6
- data/lib/opt_parse_validator/opts/headers.rb +2 -0
- data/lib/opt_parse_validator/opts/integer_range.rb +2 -1
- data/lib/opt_parse_validator/opts/multi_choices.rb +1 -2
- data/lib/opt_parse_validator/opts/smart_list.rb +28 -0
- data/lib/opt_parse_validator/opts/uri.rb +2 -0
- data/lib/opt_parse_validator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d415463f07cdf6040286e6d663e30e595dd1baa5
|
4
|
+
data.tar.gz: afd3bdd186e2509e4b7374c6922eba90c37cc350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8a1f3f9423004010b3063deac7ad196f054b1a8b5f3ca2d4a06465312a292051b384c007aa65a1556ba594cd49621fe52dc855d255195ca04cd3bc5fd1e23ec
|
7
|
+
data.tar.gz: 47629f4e35fa33ad43c2ac16682a6ef32b040828f62886259f4289ecefda410a75f46b8e0ad32fed09d1bd97335183e24a3bfe10333afe12736823a5c964fb73
|
data/README.md
CHANGED
@@ -47,6 +47,14 @@ For more option examples, see
|
|
47
47
|
|
48
48
|
Please Feel free to send Pull Requests to improve this Readme
|
49
49
|
|
50
|
+
### Global Attributes
|
51
|
+
|
52
|
+
Some attributes are available for all Validators:
|
53
|
+
- :required (whether or not the associated cli option is required/mandatory - [example](https://github.com/wpscanteam/CMSScanner/blob/master/app/controllers/core/cli_options.rb#L9)).
|
54
|
+
- :required_unless (like the above, except if the option/s given in this parameter are called in the CLI - [example](https://github.com/wpscanteam/wpscan-v3/blob/master/app/controllers/core.rb#L7), can be a single symbol or array of symbols)
|
55
|
+
- :default (Default value to use if the option is not supplied)
|
56
|
+
- :value_if_empty (Value to use if no argument has been supplied for the related option)
|
57
|
+
|
50
58
|
### Available Validators & Associated Attributes:
|
51
59
|
- Array
|
52
60
|
- :separator (default: ',')
|
@@ -72,7 +80,6 @@ Please Feel free to send Pull Requests to improve this Readme
|
|
72
80
|
- MultiChoices
|
73
81
|
- choices (mandatory)
|
74
82
|
- separator (default: ',')
|
75
|
-
- value_if_empty
|
76
83
|
- incompatible
|
77
84
|
- Positive Integer
|
78
85
|
- Path
|
@@ -87,6 +94,8 @@ Please Feel free to send Pull Requests to improve this Readme
|
|
87
94
|
- :default_protocol
|
88
95
|
- Regexp:
|
89
96
|
- :options (See http://ruby-doc.org/core-2.2.1/Regexp.html#method-c-new)
|
97
|
+
- SmartList
|
98
|
+
- separator (default: ',')
|
90
99
|
- String
|
91
100
|
- URI
|
92
101
|
- :protocols
|
@@ -10,7 +10,7 @@ module OptParseValidator
|
|
10
10
|
# @option attrs [ Boolean ] :required
|
11
11
|
# @options attrs [ Array<Symbol>, Symbol ] :required_unless
|
12
12
|
# @option attrs [ Mixed ] :default The default value to use if the option is not supplied
|
13
|
-
# @option attrs [ Mixed ] :value_if_empty The value to use if no
|
13
|
+
# @option attrs [ Mixed ] :value_if_empty The value to use if no argument has been supplied
|
14
14
|
# @option attrs [ Array<Symbol> ] :normalize See #normalize
|
15
15
|
#
|
16
16
|
# @note The :default and :normalize 'logics' are done in OptParseValidator::OptParser#add_option
|
@@ -18,12 +18,17 @@ module OptParseValidator
|
|
18
18
|
@option = option
|
19
19
|
@attrs = attrs
|
20
20
|
|
21
|
-
|
21
|
+
# TODO: incompatible attributes, ie required and require_unless at the same time
|
22
|
+
|
23
|
+
append_help_messages
|
22
24
|
end
|
23
25
|
|
24
26
|
# @return [ Void ]
|
25
27
|
def append_help_messages
|
26
28
|
option << "Default: #{default}" if default
|
29
|
+
option << "Value if no argument supplied: #{value_if_empty}" if value_if_empty
|
30
|
+
option << 'This option is mandatory' if required?
|
31
|
+
option << "This option is mandatory unless #{required_unless.join(' or ')} is/are supplied" unless required_unless.empty?
|
27
32
|
end
|
28
33
|
|
29
34
|
# @return [ Boolean ]
|
@@ -14,13 +14,9 @@ module OptParseValidator
|
|
14
14
|
|
15
15
|
# @return [ Void ]
|
16
16
|
def append_help_messages
|
17
|
-
|
17
|
+
super
|
18
18
|
|
19
|
-
choices.
|
20
|
-
msg += choice.to_s == default.to_s ? " #{choice} (default)," : " #{choice},"
|
21
|
-
end
|
22
|
-
|
23
|
-
option << msg[0..-2]
|
19
|
+
option << "Available choices: #{choices.join(', ')}"
|
24
20
|
end
|
25
21
|
|
26
22
|
# @return [ String ]
|
@@ -3,6 +3,8 @@ module OptParseValidator
|
|
3
3
|
class OptHeaders < OptBase
|
4
4
|
# @return [ Void ]
|
5
5
|
def append_help_messages
|
6
|
+
super
|
7
|
+
|
6
8
|
option << "Separator to use between the headers: '; '"
|
7
9
|
option << "Examples: 'X-Forwarded-For: 127.0.0.1', 'X-Forwarded-For: 127.0.0.1; Another: aaa'"
|
8
10
|
end
|
@@ -18,8 +18,7 @@ module OptParseValidator
|
|
18
18
|
|
19
19
|
append_choices_help_messages
|
20
20
|
|
21
|
-
|
22
|
-
option << "If no choice is supplied, '#{value_if_empty}' will be used" if value_if_empty
|
21
|
+
super
|
23
22
|
|
24
23
|
append_incompatible_help_messages
|
25
24
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module OptParseValidator
|
2
|
+
# Implementation of the SmartList Option
|
3
|
+
# Such option allow users to supply a list like
|
4
|
+
# - name1
|
5
|
+
# - name1,name2,name3
|
6
|
+
# - /tmp/names.txt
|
7
|
+
class OptSmartList < OptArray
|
8
|
+
# @return [ Void ]
|
9
|
+
def append_help_messages
|
10
|
+
super
|
11
|
+
# removes the help message from OptArray about the separator as useless here
|
12
|
+
# can't use option as it's an attr_reader only
|
13
|
+
@option -= ["Separator to use between the values: '#{separator}'"]
|
14
|
+
|
15
|
+
option << "Examples: 'a1', '#{%w[a1 a2 a3].join(separator)}', '/tmp/a.txt'"
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param [ String ] value
|
19
|
+
#
|
20
|
+
# @return [ Array<String> ]
|
21
|
+
def validate(value)
|
22
|
+
# Might be a better way to do this especially with a big file
|
23
|
+
File.open(value).map(&:chomp)
|
24
|
+
rescue Errno::ENOENT
|
25
|
+
super(value)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -5,6 +5,8 @@ module OptParseValidator
|
|
5
5
|
def append_help_messages
|
6
6
|
option << "Allowed Protocols: #{allowed_protocols.join(', ')}" unless allowed_protocols.empty?
|
7
7
|
option << "Default Protocol if none provided: #{default_protocol}" if default_protocol
|
8
|
+
|
9
|
+
super
|
8
10
|
end
|
9
11
|
|
10
12
|
# @return [ Array<String> ]
|
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: 0.0.13.
|
4
|
+
version: 0.0.13.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WPScanTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/opt_parse_validator/opts/positive_integer.rb
|
171
171
|
- lib/opt_parse_validator/opts/proxy.rb
|
172
172
|
- lib/opt_parse_validator/opts/regexp.rb
|
173
|
+
- lib/opt_parse_validator/opts/smart_list.rb
|
173
174
|
- lib/opt_parse_validator/opts/string.rb
|
174
175
|
- lib/opt_parse_validator/opts/uri.rb
|
175
176
|
- lib/opt_parse_validator/opts/url.rb
|