samovar 2.1.4 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data/lib/samovar/command.rb +18 -21
- data/lib/samovar/error.rb +4 -19
- data/lib/samovar/failure.rb +4 -19
- data/lib/samovar/flags.rb +73 -39
- data/lib/samovar/many.rb +4 -19
- data/lib/samovar/nested.rb +4 -19
- data/lib/samovar/one.rb +4 -19
- data/lib/samovar/option.rb +6 -20
- data/lib/samovar/options.rb +7 -20
- data/lib/samovar/output/columns.rb +4 -19
- data/lib/samovar/output/header.rb +4 -19
- data/lib/samovar/output/row.rb +4 -19
- data/lib/samovar/output/rows.rb +4 -19
- data/lib/samovar/output/usage_formatter.rb +4 -19
- data/lib/samovar/output.rb +4 -19
- data/lib/samovar/split.rb +4 -19
- data/lib/samovar/table.rb +7 -21
- data/lib/samovar/version.rb +6 -20
- data/lib/samovar.rb +4 -19
- data/license.md +22 -0
- data/{README.md → readme.md} +37 -53
- data.tar.gz.sig +0 -0
- metadata +46 -96
- metadata.gz.sig +0 -0
- data/.gitignore +0 -11
- data/.rspec +0 -4
- data/.travis.yml +0 -20
- data/Gemfile +0 -8
- data/Rakefile +0 -9
- data/samovar.gemspec +0 -28
- data/spec/samovar/coerce_spec.rb +0 -45
- data/spec/samovar/command_spec.rb +0 -91
- data/spec/samovar/many_spec.rb +0 -49
- data/spec/samovar/nested_spec.rb +0 -111
- data/spec/samovar/one_spec.rb +0 -49
- data/spec/samovar/options_spec.rb +0 -50
- data/spec/samovar/split_spec.rb +0 -49
- data/spec/samovar/table_spec.rb +0 -39
- data/spec/spec_helper.rb +0 -32
- data/teapot.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e30e7064ff47b5ddb9d3461d291513e310fe7000d96abf00c473447d76c4f17
|
4
|
+
data.tar.gz: 3ec1e17b743863c3df573f959450922c9aec4fcedbf4fe8a690657effcc643f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16adeb378b0451726310d57f76b7223c37a51a43fbf21d1348c3d309b94ae1b99fb943736362c3c66f0b1c651630982f9a5eba5b32bfb8202c0704370e67a6cc
|
7
|
+
data.tar.gz: b9bbcfbdc77d330992c47eebfdb10c612d57f140ef0b6e8f97204e3d67d2ccf2f020313cdf54c816122cebb279c82a315db40820d60ef74f41de118c7f5d4873
|
checksums.yaml.gz.sig
ADDED
data/lib/samovar/command.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
require_relative 'table'
|
22
7
|
require_relative 'options'
|
@@ -61,6 +46,11 @@ module Samovar
|
|
61
46
|
end
|
62
47
|
|
63
48
|
def self.append(row)
|
49
|
+
if method_defined?(row.key, false)
|
50
|
+
warning "Method for key #{row.key} is already defined!", caller
|
51
|
+
# raise ArgumentError, "Method for key #{row.key} is already defined!"
|
52
|
+
end
|
53
|
+
|
64
54
|
attr_accessor(row.key) if row.respond_to?(:key)
|
65
55
|
|
66
56
|
self.table << row
|
@@ -108,13 +98,20 @@ module Samovar
|
|
108
98
|
end
|
109
99
|
end
|
110
100
|
|
111
|
-
def initialize(input = nil, name: File.basename($0), parent: nil)
|
101
|
+
def initialize(input = nil, name: File.basename($0), parent: nil, output: nil)
|
112
102
|
@name = name
|
113
103
|
@parent = parent
|
104
|
+
@output = output
|
114
105
|
|
115
106
|
parse(input) if input
|
116
107
|
end
|
117
108
|
|
109
|
+
attr :output
|
110
|
+
|
111
|
+
def output
|
112
|
+
@output || $stdout
|
113
|
+
end
|
114
|
+
|
118
115
|
def to_s
|
119
116
|
self.class.name
|
120
117
|
end
|
@@ -136,7 +133,7 @@ module Samovar
|
|
136
133
|
end
|
137
134
|
end
|
138
135
|
|
139
|
-
def print_usage(output:
|
136
|
+
def print_usage(output: self.output, formatter: Output::UsageFormatter, &block)
|
140
137
|
rows = Output::Rows.new
|
141
138
|
|
142
139
|
self.class.usage(rows, @name)
|
data/lib/samovar/error.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class Error < StandardError
|
data/lib/samovar/failure.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2017-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class Failure < RuntimeError
|
data/lib/samovar/flags.rb
CHANGED
@@ -1,29 +1,14 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class Flags
|
23
8
|
def initialize(text)
|
24
9
|
@text = text
|
25
10
|
|
26
|
-
@ordered = text.split(/\s+\|\s+/).map{|part| Flag.
|
11
|
+
@ordered = text.split(/\s+\|\s+/).map{|part| Flag.parse(part)}
|
27
12
|
end
|
28
13
|
|
29
14
|
def each(&block)
|
@@ -36,7 +21,7 @@ module Samovar
|
|
36
21
|
|
37
22
|
# Whether or not this flag should have a true/false value if not specified otherwise.
|
38
23
|
def boolean?
|
39
|
-
@ordered.count == 1 and @ordered.first.
|
24
|
+
@ordered.count == 1 and @ordered.first.boolean?
|
40
25
|
end
|
41
26
|
|
42
27
|
def count
|
@@ -44,12 +29,13 @@ module Samovar
|
|
44
29
|
end
|
45
30
|
|
46
31
|
def to_s
|
47
|
-
|
32
|
+
"[#{@ordered.join(' | ')}]"
|
48
33
|
end
|
49
34
|
|
50
35
|
def parse(input)
|
51
36
|
@ordered.each do |flag|
|
52
|
-
|
37
|
+
result = flag.parse(input)
|
38
|
+
if result != nil
|
53
39
|
return result
|
54
40
|
end
|
55
41
|
end
|
@@ -59,45 +45,93 @@ module Samovar
|
|
59
45
|
end
|
60
46
|
|
61
47
|
class Flag
|
62
|
-
def
|
63
|
-
@text = text
|
64
|
-
|
48
|
+
def self.parse(text)
|
65
49
|
if text =~ /(.*?)\s(\<.*?\>)/
|
66
|
-
|
67
|
-
|
50
|
+
ValueFlag.new(text, $1, $2)
|
51
|
+
elsif text =~ /--\[no\]-(.*?)$/
|
52
|
+
BooleanFlag.new(text, "--#{$1}")
|
68
53
|
else
|
69
|
-
|
70
|
-
@value = nil
|
54
|
+
ValueFlag.new(text, text, nil)
|
71
55
|
end
|
72
|
-
|
73
|
-
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(text, prefix, alternatives = nil)
|
59
|
+
@text = text
|
60
|
+
@prefix = prefix
|
61
|
+
@alternatives = alternatives
|
74
62
|
end
|
75
63
|
|
76
64
|
attr :text
|
77
65
|
attr :prefix
|
78
66
|
attr :alternatives
|
79
|
-
attr :value
|
80
67
|
|
81
68
|
def to_s
|
82
69
|
@text
|
83
70
|
end
|
84
71
|
|
85
|
-
def prefix?(token)
|
86
|
-
@prefix == token or @alternatives.include?(token)
|
87
|
-
end
|
88
|
-
|
89
72
|
def key
|
90
73
|
@key ||= @prefix.sub(/^-*/, '').gsub('-', '_').to_sym
|
91
74
|
end
|
92
75
|
|
76
|
+
def boolean?
|
77
|
+
false
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class ValueFlag < Flag
|
82
|
+
def initialize(text, prefix, value)
|
83
|
+
super(text, prefix)
|
84
|
+
|
85
|
+
@value = value
|
86
|
+
|
87
|
+
*@alternatives, @prefix = @prefix.split('/')
|
88
|
+
end
|
89
|
+
|
90
|
+
attr :alternatives
|
91
|
+
attr :value
|
92
|
+
|
93
|
+
def boolean?
|
94
|
+
@value.nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
def prefix?(token)
|
98
|
+
@prefix == token or @alternatives.include?(token)
|
99
|
+
end
|
100
|
+
|
93
101
|
def parse(input)
|
94
102
|
if prefix?(input.first)
|
95
103
|
if @value
|
96
|
-
input.shift(2).last
|
104
|
+
return input.shift(2).last
|
97
105
|
else
|
98
|
-
input.shift
|
106
|
+
input.shift
|
107
|
+
return key
|
99
108
|
end
|
100
109
|
end
|
101
110
|
end
|
102
111
|
end
|
112
|
+
|
113
|
+
class BooleanFlag < Flag
|
114
|
+
def initialize(text, prefix, value = nil)
|
115
|
+
super(text, prefix)
|
116
|
+
|
117
|
+
@value = value
|
118
|
+
|
119
|
+
@negated = @prefix.sub(/^--/, '--no-')
|
120
|
+
@alternatives = [@negated]
|
121
|
+
end
|
122
|
+
|
123
|
+
def prefix?(token)
|
124
|
+
@prefix == token or @negated == token
|
125
|
+
end
|
126
|
+
|
127
|
+
def parse(input)
|
128
|
+
if input.first == @prefix
|
129
|
+
input.shift
|
130
|
+
return true
|
131
|
+
elsif input.first == @negated
|
132
|
+
input.shift
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
103
137
|
end
|
data/lib/samovar/many.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class Many
|
data/lib/samovar/nested.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class Nested
|
data/lib/samovar/one.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
class One
|
data/lib/samovar/option.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
require_relative 'flags'
|
22
7
|
|
@@ -81,7 +66,8 @@ module Samovar
|
|
81
66
|
end
|
82
67
|
|
83
68
|
def parse(input, parent = nil, default = nil)
|
84
|
-
|
69
|
+
result = @flags.parse(input)
|
70
|
+
if result != nil
|
85
71
|
@value.nil? ? coerce(result) : @value
|
86
72
|
elsif default ||= @default
|
87
73
|
return default
|
data/lib/samovar/options.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
require_relative 'option'
|
22
7
|
|
@@ -105,7 +90,9 @@ module Samovar
|
|
105
90
|
values = (default || @defaults).dup
|
106
91
|
|
107
92
|
while option = @keyed[input.first]
|
108
|
-
|
93
|
+
prefix = input.first
|
94
|
+
result = option.parse(input)
|
95
|
+
if result != nil
|
109
96
|
values[option.key] = result
|
110
97
|
end
|
111
98
|
end
|
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
module Output
|
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
module Output
|
data/lib/samovar/output/row.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
module Samovar
|
22
7
|
module Output
|
data/lib/samovar/output/rows.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
require_relative 'header'
|
22
7
|
require_relative 'columns'
|
@@ -1,22 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
require 'mapping/model'
|
22
7
|
require 'console/terminal'
|
data/lib/samovar/output.rb
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2023, by Samuel Williams.
|
20
5
|
|
21
6
|
require_relative 'output/usage_formatter'
|