options_by_example 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/options_by_example/version.rb +7 -1
- data/lib/options_by_example.rb +21 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5533bd626a90e56af73f7fe32cbd2c0a79630da399242c98abce184ac084dd9
|
4
|
+
data.tar.gz: 4583a92414c1e10544ffb42b4e45da0d1c0eac1adc1d38748bd31e24e791337e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7df1507d066462d1031d71dc054fa886764dddca9fe17b4d6f7310f9e17f75673a6a6709e6ef1636d863dd35a537918d9e6838a04981cd947174d402569480
|
7
|
+
data.tar.gz: 9f11d4fdae24faefc1069435683e65c648635568d54d19e3e8197040b721db3630be4aa779781403d26b5c2e04dd23b3b6bcc0e3bef11d405855ac07e89a0630
|
data/README.md
CHANGED
@@ -30,15 +30,15 @@ require 'options_by_example'
|
|
30
30
|
|
31
31
|
Options = OptionsByExample.read(DATA).parse(ARGV)
|
32
32
|
|
33
|
-
puts Options.
|
34
|
-
puts Options.
|
35
|
-
puts Options.
|
36
|
-
puts Options.
|
37
|
-
puts Options.
|
38
|
-
puts Options.
|
39
|
-
puts Options.
|
40
|
-
puts Options.
|
41
|
-
puts Options.
|
33
|
+
puts Options.include? :secure
|
34
|
+
puts Options.include? :verbose
|
35
|
+
puts Options.include? :retries
|
36
|
+
puts Options.include? :timeout
|
37
|
+
puts Options.get :retries
|
38
|
+
puts Options.get :timeout
|
39
|
+
puts Options.get :mode
|
40
|
+
puts Options.get :host
|
41
|
+
puts Options.get :port
|
42
42
|
|
43
43
|
|
44
44
|
__END__
|
@@ -50,8 +50,8 @@ Usage: connect [options] [mode] host port
|
|
50
50
|
Options:
|
51
51
|
-s, --secure Establish a secure connection (SSL/TSL)
|
52
52
|
-v, --verbose Enable verbose output for detailed information
|
53
|
-
-r, --retries NUM
|
54
|
-
-t, --timeout NUM Set
|
53
|
+
-r, --retries NUM Number of connection retries (default 3)
|
54
|
+
-t, --timeout NUM Set connection timeout in seconds
|
55
55
|
|
56
56
|
Arguments:
|
57
57
|
[mode] Optional connection mode (active or passive)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class OptionsByExample
|
4
|
-
VERSION = '3.
|
4
|
+
VERSION = '3.2.0'
|
5
5
|
end
|
6
6
|
|
7
7
|
|
@@ -11,6 +11,12 @@ __END__
|
|
11
11
|
# Minor version bump when backward-compatible changes or enhancements
|
12
12
|
# Patch version bump when backward-compatible bug fixes, security updates etc
|
13
13
|
|
14
|
+
3.2.0
|
15
|
+
|
16
|
+
- New method #get returns argument value or nil
|
17
|
+
- New method #fetch returns argument value or raises error
|
18
|
+
- Changed internal method #parse_without_exit to private
|
19
|
+
|
14
20
|
3.1.0
|
15
21
|
|
16
22
|
- Support dash in argument and option names
|
data/lib/options_by_example.rb
CHANGED
@@ -8,6 +8,7 @@ class OptionsByExample
|
|
8
8
|
|
9
9
|
attr_reader :arguments
|
10
10
|
attr_reader :options
|
11
|
+
attr_reader :usage_message
|
11
12
|
|
12
13
|
def self.read(data)
|
13
14
|
return new data.read
|
@@ -61,19 +62,12 @@ class OptionsByExample
|
|
61
62
|
exit 1
|
62
63
|
end
|
63
64
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
@argument_names_optional,
|
68
|
-
@default_values,
|
69
|
-
@option_names,
|
70
|
-
)
|
71
|
-
|
72
|
-
parser.parse argv
|
73
|
-
@arguments = parser.arguments
|
74
|
-
@options = parser.options
|
65
|
+
def fetch(*args, &block)
|
66
|
+
@arguments.fetch(*args, &block)
|
67
|
+
end
|
75
68
|
|
76
|
-
|
69
|
+
def get(name)
|
70
|
+
@arguments[name]
|
77
71
|
end
|
78
72
|
|
79
73
|
def if_present(name)
|
@@ -89,6 +83,21 @@ class OptionsByExample
|
|
89
83
|
|
90
84
|
private
|
91
85
|
|
86
|
+
def parse_without_exit(argv)
|
87
|
+
parser = Parser.new(
|
88
|
+
@argument_names_required,
|
89
|
+
@argument_names_optional,
|
90
|
+
@default_values,
|
91
|
+
@option_names,
|
92
|
+
)
|
93
|
+
|
94
|
+
parser.parse argv
|
95
|
+
@arguments = parser.arguments
|
96
|
+
@options = parser.options
|
97
|
+
|
98
|
+
return self
|
99
|
+
end
|
100
|
+
|
92
101
|
def initialize_argument_accessors
|
93
102
|
[
|
94
103
|
*@argument_names_required,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: options_by_example
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Kuhn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|