eac_cli 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_cli/definition/base_option.rb +3 -1
- data/lib/eac_cli/definition/default_value.rb +17 -0
- data/lib/eac_cli/runner_with/help/builder.rb +8 -26
- data/lib/eac_cli/runner_with/help/layout.rb +40 -0
- data/lib/eac_cli/runner_with/help.rb +12 -0
- data/lib/eac_cli/runner_with/input.rb +1 -1
- data/lib/eac_cli/runner_with/output.rb +1 -1
- data/lib/eac_cli/runner_with/subcommands.rb +1 -4
- data/lib/eac_cli/version.rb +1 -1
- metadata +6 -5
- data/lib/eac_cli/runner_with/help/list_section.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db28e2122721492b5bb7243a022a5b53771166d3310bb75339901e9d4d216072
|
4
|
+
data.tar.gz: 0e8a60069bc925dc4ca2e54d98168aee9963b684cbce9c427d4f27087901e653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d640ebbe8a9fa2f1857c14ab2a5bc13aeb06dfdacde17568fe6706c7defad382d751cdbde4d1253e8b24789763c0bc58fb87c977e293b9debc05c6551eb1f9
|
7
|
+
data.tar.gz: 414fb900c66c2277234c167495f0e2a7fac008d02e57b76d092961ababa8ed0a39be741b9d927c99992d0f4c1c730de9b6748b035d4230aee75fb9402bba1707
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_cli/definition/default_value'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module EacCli
|
6
7
|
class Definition
|
7
8
|
class BaseOption
|
8
9
|
require_sub __FILE__
|
10
|
+
include ::EacCli::Definition::DefaultValue
|
9
11
|
|
10
12
|
class << self
|
11
13
|
def from_args(args)
|
@@ -17,7 +19,7 @@ module EacCli
|
|
17
19
|
DEFAULT_REQUIRED = false
|
18
20
|
|
19
21
|
enable_listable
|
20
|
-
enable_abstract_methods :build_value
|
22
|
+
enable_abstract_methods :build_value
|
21
23
|
lists.add_symbol :option, :default, :optional, :usage, :repeat, :required
|
22
24
|
common_constructor :short, :long, :description, :options, default: [{}] do
|
23
25
|
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Definition
|
7
|
+
module DefaultValue
|
8
|
+
def default_value
|
9
|
+
default_value? ? options[OPTION_DEFAULT] : default_default_value
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_value?
|
13
|
+
options.key?(OPTION_DEFAULT)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_cli/runner_with/help/
|
3
|
+
require 'eac_cli/runner_with/help/layout'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
|
6
6
|
module EacCli
|
7
7
|
module RunnerWith
|
8
8
|
module Help
|
9
9
|
class Builder
|
10
|
+
include ::EacCli::RunnerWith::Help::Layout
|
10
11
|
require_sub __FILE__, require_dependency: true
|
11
12
|
common_constructor :runner
|
12
13
|
|
13
|
-
OPTION_DESC_SEP = ::EacCli::RunnerWith::Help::ListSection::IDENTATION * 2
|
14
|
-
SECTION_SEPARATOR = "\n"
|
15
|
-
|
16
14
|
class << self
|
17
15
|
def option_long(option)
|
18
16
|
b = option.long
|
@@ -35,7 +33,7 @@ module EacCli
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def word_separator
|
38
|
-
|
36
|
+
WORD_SEPARATOR
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
@@ -45,36 +43,22 @@ module EacCli
|
|
45
43
|
runner.class.runner_definition
|
46
44
|
end
|
47
45
|
|
48
|
-
# @return [String, nil]
|
49
|
-
def extra_section
|
50
|
-
ess = extra_sections
|
51
|
-
return nil if ess.none?
|
52
|
-
|
53
|
-
ess.join(SECTION_SEPARATOR)
|
54
|
-
end
|
55
|
-
|
56
46
|
# @return [Enumerable<String>]
|
57
47
|
def extra_sections
|
58
48
|
runner.if_respond(:help_extra_text, []) do |v|
|
59
|
-
|
60
|
-
v.map do |title, lines|
|
61
|
-
::EacCli::RunnerWith::Help::ListSection.new(title, lines)
|
62
|
-
end
|
63
|
-
else
|
64
|
-
[v.to_s]
|
65
|
-
end
|
49
|
+
[v.to_s]
|
66
50
|
end
|
67
51
|
end
|
68
52
|
|
69
53
|
def option_definition(option)
|
70
54
|
[self.class.option_usage_full(option), option.description,
|
71
55
|
option.default_value? ? "[Default: \"#{option.default_value}\"]" : nil]
|
72
|
-
.reject(&:blank?).join(
|
56
|
+
.reject(&:blank?).join(OPTION_DESCRIPTION_SEPARATOR)
|
73
57
|
end
|
74
58
|
|
75
59
|
# @return [String]
|
76
60
|
def options_section
|
77
|
-
|
61
|
+
list_section(
|
78
62
|
'Options',
|
79
63
|
definition.alternatives.flat_map(&:options).map { |option| option_definition(option) }
|
80
64
|
)
|
@@ -82,16 +66,14 @@ module EacCli
|
|
82
66
|
|
83
67
|
# @return [String]
|
84
68
|
def usage_section
|
85
|
-
|
69
|
+
list_section(
|
86
70
|
'Usage',
|
87
71
|
definition.alternatives.map { |alternative| self.alternative(alternative) }
|
88
72
|
)
|
89
73
|
end
|
90
74
|
|
91
75
|
def to_s
|
92
|
-
|
93
|
-
.map { |s| "#{s}#{SECTION_SEPARATOR}" }.join
|
94
|
-
extra_section.if_present(r) { |v| r + v }
|
76
|
+
join_sections(definition.description, usage_section, options_section, *extra_sections)
|
95
77
|
end
|
96
78
|
end
|
97
79
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
module RunnerWith
|
7
|
+
module Help
|
8
|
+
module Layout
|
9
|
+
common_concern do
|
10
|
+
include InstanceClassMethods
|
11
|
+
extend InstanceClassMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
module InstanceClassMethods
|
15
|
+
WORD_SEPARATOR = ' '
|
16
|
+
IDENTATION = WORD_SEPARATOR * 2
|
17
|
+
OPTION_DESCRIPTION_SEPARATOR = IDENTATION * 2
|
18
|
+
LINE_BREAK = "\n"
|
19
|
+
SECTION_SEPARATOR = LINE_BREAK * 2
|
20
|
+
|
21
|
+
# @param title String
|
22
|
+
# @param items [Enumerable<String>]
|
23
|
+
# @return [String]
|
24
|
+
def list_section(title, items)
|
25
|
+
(["#{title}:"] + items.map { |line| "#{IDENTATION}#{line}" })
|
26
|
+
.map { |line| "#{line}\n" }.join
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param sections [Enumerable<String>]
|
30
|
+
# @return [String]
|
31
|
+
def join_sections(*sections)
|
32
|
+
sections.map { |s| s.to_s.strip }.join(SECTION_SEPARATOR) + LINE_BREAK
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
extend InstanceClassMethods
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -20,6 +20,18 @@ module EacCli
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# @param items [Enumerable<String>]
|
24
|
+
# @return [String]
|
25
|
+
def help_list_section(title, items)
|
26
|
+
::EacCli::RunnerWith::Help::Layout.list_section(title, items)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param items [Enumerable<String>]
|
30
|
+
# @return [String]
|
31
|
+
def help_join_sections(*sections)
|
32
|
+
::EacCli::RunnerWith::Help::Layout.join_sections(*sections)
|
33
|
+
end
|
34
|
+
|
23
35
|
def help_run
|
24
36
|
return unless show_help?
|
25
37
|
|
@@ -53,10 +53,7 @@ module EacCli
|
|
53
53
|
|
54
54
|
# @return [Hash<String, Enumerable<String>]
|
55
55
|
def help_extra_text
|
56
|
-
|
57
|
-
'Subcommands' =>
|
58
|
-
available_subcommands.keys.sort
|
59
|
-
}
|
56
|
+
help_list_section('Subcommands', available_subcommands.keys.sort)
|
60
57
|
end
|
61
58
|
|
62
59
|
def method_missing(method_name, *arguments, &block)
|
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.33.0
|
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: 2023-05-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.114'
|
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.114'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: eac_ruby_gem_support
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/eac_cli/definition/base_option.rb
|
93
93
|
- lib/eac_cli/definition/base_option/initialize_args_parser.rb
|
94
94
|
- lib/eac_cli/definition/boolean_option.rb
|
95
|
+
- lib/eac_cli/definition/default_value.rb
|
95
96
|
- lib/eac_cli/definition/positional_argument.rb
|
96
97
|
- lib/eac_cli/enum.rb
|
97
98
|
- lib/eac_cli/old_configs.rb
|
@@ -126,7 +127,7 @@ files:
|
|
126
127
|
- lib/eac_cli/runner_with/help.rb
|
127
128
|
- lib/eac_cli/runner_with/help/builder.rb
|
128
129
|
- lib/eac_cli/runner_with/help/builder/alternative.rb
|
129
|
-
- lib/eac_cli/runner_with/help/
|
130
|
+
- lib/eac_cli/runner_with/help/layout.rb
|
130
131
|
- lib/eac_cli/runner_with/input.rb
|
131
132
|
- lib/eac_cli/runner_with/output.rb
|
132
133
|
- lib/eac_cli/runner_with/subcommands.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacCli
|
6
|
-
module RunnerWith
|
7
|
-
module Help
|
8
|
-
class ListSection
|
9
|
-
WORD_SEPARATOR = ' '
|
10
|
-
IDENTATION = WORD_SEPARATOR * 2
|
11
|
-
|
12
|
-
common_constructor :title, :items
|
13
|
-
|
14
|
-
# @return [String]
|
15
|
-
def to_s
|
16
|
-
(["#{title}:"] + items.map { |line| "#{IDENTATION}#{line}" })
|
17
|
-
.map { |line| "#{line}\n" }.join
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|