opt_parse_validator 0.0.13.7 → 0.0.13.8
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 +40 -1
- data/lib/opt_parse_validator.rb +2 -2
- data/lib/opt_parse_validator/opts/headers.rb +1 -0
- data/lib/opt_parse_validator/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: f8b96bf2df00c21b5dd5be7b553495196f7f7190
|
4
|
+
data.tar.gz: 7091246c62fe01bb6a1437ba265ef5d755409d46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0338d5ddadd4aeef34af392f5aa3d51ada1deb93cffe3f04cb7fb86073c6c8613e8b9b70f78b833a2106e2ff9ac35605b9b65b792cb3f66eb2ecf859c7fcea5f'
|
7
|
+
data.tar.gz: b0641b222b4f7ff8136e5bfaa4d6fb2d2e61543ed1fd915e526470b4ae03282b38ac9ee143bce8f077f0f9180053bbd17fbc021028cc3b7e22f8a6c09a05d317
|
data/README.md
CHANGED
@@ -8,7 +8,46 @@ OptParseValidator
|
|
8
8
|
[](https://gemnasium.com/wpscanteam/OptParseValidator)
|
9
9
|
|
10
10
|
|
11
|
-
###
|
11
|
+
### Installation
|
12
|
+
|
13
|
+
```gem install opt_parse_validator```
|
14
|
+
|
15
|
+
### Usage Example
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
# test.rb
|
19
|
+
|
20
|
+
require 'opt_parse_validator'
|
21
|
+
|
22
|
+
# For contructor options, such as setting a banner, the summary width and indent,
|
23
|
+
# see http://ruby-doc.org/stdlib-2.4.2/libdoc/optparse/rdoc/OptionParser.html#method-c-new
|
24
|
+
parser = OptParseValidator::OptParser.new
|
25
|
+
|
26
|
+
parser.add(
|
27
|
+
OptParseValidator::OptString.new(['-m', '--mandatory PARAM', 'A Mandatory CLI option'], required: true),
|
28
|
+
OptParseValidator::OptBoolean.new(['--test', '-t', 'Option Helper Message']),
|
29
|
+
OptParseValidator::OptFilePath.new(['-o', '--output FILE', 'Output to FILE'], writable: true, exists: false)
|
30
|
+
)
|
31
|
+
|
32
|
+
begin
|
33
|
+
p parser.results
|
34
|
+
rescue OptParseValidator::Error => e
|
35
|
+
puts 'Parsing Error: ' + e.message
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
Then have a play with
|
40
|
+
```ruby test.rb -h```
|
41
|
+
```ruby test.rb -m hh -t```
|
42
|
+
```ruby test.rb -t```
|
43
|
+
|
44
|
+
For more option examples, see
|
45
|
+
- https://github.com/wpscanteam/CMSScanner/blob/master/app/controllers/core/cli_options.rb
|
46
|
+
- https://github.com/wpscanteam/wpscan-v3/blob/master/app/controllers/enumeration/cli_options.rb
|
47
|
+
|
48
|
+
Please Feel free to send Pull Requests to improve this Readme
|
49
|
+
|
50
|
+
### Available Validators & Associated Attributes:
|
12
51
|
- Array
|
13
52
|
- :separator (default: ',')
|
14
53
|
- Boolean
|
data/lib/opt_parse_validator.rb
CHANGED
@@ -46,7 +46,7 @@ module OptParseValidator
|
|
46
46
|
on(*opt.option) do |arg|
|
47
47
|
begin
|
48
48
|
@results[opt.to_sym] = opt.normalize(opt.validate(arg))
|
49
|
-
rescue => e
|
49
|
+
rescue StandardError => e
|
50
50
|
# Adds the long option name to the message
|
51
51
|
# And raises it as an OptParseValidator::Error if not already one
|
52
52
|
# e.g --proxy Invalid Scheme format.
|
@@ -72,7 +72,7 @@ module OptParseValidator
|
|
72
72
|
post_processing
|
73
73
|
|
74
74
|
@results
|
75
|
-
rescue => e
|
75
|
+
rescue StandardError => e
|
76
76
|
# Raise it as an OptParseValidator::Error if not already one
|
77
77
|
raise e.is_a?(Error) ? e.class : Error, e.message
|
78
78
|
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: 0.0.13.
|
4
|
+
version: 0.0.13.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WPScanTeam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|