eac_cli 0.22.2 → 0.24.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/eac_cli/config.rb +6 -3
- data/lib/eac_cli/definition/argument_option.rb +1 -1
- data/lib/eac_cli/definition/base_option.rb +9 -1
- data/lib/eac_cli/definition/boolean_option.rb +6 -0
- data/lib/eac_cli/enum.rb +45 -0
- data/lib/eac_cli/runner_with/help/builder.rb +3 -3
- data/lib/eac_cli/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 732a1f8ce5e5dc0a0866646c056d9beadb0792d6fa5d49d778b2781d415e3894
|
4
|
+
data.tar.gz: a3a6c28a58b3547fc4f6d79e613612e7d39cb08c3b693c6195509a65aabb2625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a49116714b16d94950d8535fb5e120ad35bb3bc2729e5b35e65b1e33ada05ae46fb92b41034379a8fe8e90e15217328f950153c4758c9df2269295e53f3ed2
|
7
|
+
data.tar.gz: 0aa191f78fa604940d4584d04a081a5739d821b9b13a23bbf6ba4638b2786ef637432aca43f10ef53b01c14b3e4e1e9284a13371ac36ed39d52d1a10a6cc59e6
|
data/lib/eac_cli/config.rb
CHANGED
@@ -3,16 +3,19 @@
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
|
5
5
|
module EacCli
|
6
|
-
class Config
|
6
|
+
class Config < ::SimpleDelegator
|
7
7
|
require_sub __FILE__
|
8
|
-
attr_reader :sub
|
9
8
|
|
10
9
|
def initialize(sub_node)
|
11
|
-
|
10
|
+
super(sub_node)
|
12
11
|
end
|
13
12
|
|
14
13
|
def entry(path, options = {})
|
15
14
|
::EacCli::Config::Entry.new(self, path, options)
|
16
15
|
end
|
16
|
+
|
17
|
+
def sub
|
18
|
+
__getobj__
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
@@ -18,7 +18,7 @@ module EacCli
|
|
18
18
|
|
19
19
|
enable_listable
|
20
20
|
enable_abstract_methods :build_value, :default_value
|
21
|
-
lists.add_symbol :option, :optional, :usage, :repeat, :required
|
21
|
+
lists.add_symbol :option, :default, :optional, :usage, :repeat, :required
|
22
22
|
common_constructor :short, :long, :description, :options, default: [{}] do
|
23
23
|
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
24
24
|
|
@@ -27,6 +27,14 @@ module EacCli
|
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
+
def default_value
|
31
|
+
default_value? ? options[OPTION_DEFAULT] : default_default_value
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_value?
|
35
|
+
options.key?(OPTION_DEFAULT)
|
36
|
+
end
|
37
|
+
|
30
38
|
def identifier
|
31
39
|
[long, short].each do |v|
|
32
40
|
v.to_s.if_present { |vv| return vv.variableize.to_sym }
|
data/lib/eac_cli/enum.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/enum'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
# A [EacRubyUtils::Enum] which each value is associated with one console color.
|
8
|
+
class Enum < ::EacRubyUtils::Enum
|
9
|
+
# Foreground color used in [to_bg_label]
|
10
|
+
TO_BG_LABEL_FG_COLOR = :light_white
|
11
|
+
|
12
|
+
attr_reader :color
|
13
|
+
|
14
|
+
def initialize(key, color)
|
15
|
+
super(key)
|
16
|
+
@color = color
|
17
|
+
end
|
18
|
+
|
19
|
+
delegate :to_s, to: :key
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def to_label
|
23
|
+
to_fg_label
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def to_fg_label
|
28
|
+
to_fg_bg_label(color)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String]
|
32
|
+
def to_bg_label
|
33
|
+
to_fg_bg_label(TO_BG_LABEL_FG_COLOR, color)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def to_fg_bg_label(fg_color, bg_color = nil)
|
40
|
+
colors = { color: fg_color }
|
41
|
+
bg_color.if_present { |v| colors[:background] = v }
|
42
|
+
::ColorizedString[to_s].colorize(colors)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -36,9 +36,9 @@ module EacCli
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def option_definition(option)
|
39
|
-
self.class.option_usage_full(option)
|
40
|
-
|
41
|
-
|
39
|
+
[self.class.option_usage_full(option), option.description,
|
40
|
+
option.default_value? ? "[Default: \"#{option.default_value}\"]" : nil]
|
41
|
+
.reject(&:blank?).join(OPTION_DESC_SEP)
|
42
42
|
end
|
43
43
|
|
44
44
|
def section(header, include_header = true)
|
data/lib/eac_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0.5'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.5.
|
36
|
+
version: 0.5.3
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: '0.5'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.5.
|
46
|
+
version: 0.5.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: eac_ruby_utils
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.80'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
60
|
+
version: '0.80'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: eac_ruby_gem_support
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/eac_cli/definition/boolean_option.rb
|
95
95
|
- lib/eac_cli/definition/help_formatter.rb
|
96
96
|
- lib/eac_cli/definition/positional_argument.rb
|
97
|
+
- lib/eac_cli/enum.rb
|
97
98
|
- lib/eac_cli/old_configs.rb
|
98
99
|
- lib/eac_cli/old_configs/entry_reader.rb
|
99
100
|
- lib/eac_cli/old_configs/password_entry_reader.rb
|