eac_cli 0.31.0 → 0.33.0
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/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 +22 -23
- data/lib/eac_cli/runner_with/help/layout.rb +40 -0
- data/lib/eac_cli/runner_with/help.rb +15 -4
- 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 +2 -2
- data/lib/eac_cli/version.rb +1 -1
- metadata +6 -4
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/layout'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module EacCli
|
6
7
|
module RunnerWith
|
7
8
|
module Help
|
8
9
|
class Builder
|
10
|
+
include ::EacCli::RunnerWith::Help::Layout
|
9
11
|
require_sub __FILE__, require_dependency: true
|
10
12
|
common_constructor :runner
|
11
13
|
|
12
|
-
SEP = ' '
|
13
|
-
IDENT = SEP * 2
|
14
|
-
OPTION_DESC_SEP = IDENT * 2
|
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,37 @@ module EacCli
|
|
45
43
|
runner.class.runner_definition
|
46
44
|
end
|
47
45
|
|
46
|
+
# @return [Enumerable<String>]
|
47
|
+
def extra_sections
|
48
|
+
runner.if_respond(:help_extra_text, []) do |v|
|
49
|
+
[v.to_s]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
48
53
|
def option_definition(option)
|
49
54
|
[self.class.option_usage_full(option), option.description,
|
50
55
|
option.default_value? ? "[Default: \"#{option.default_value}\"]" : nil]
|
51
|
-
.reject(&:blank?).join(
|
52
|
-
end
|
53
|
-
|
54
|
-
def section(header, include_header = true)
|
55
|
-
b = include_header ? "#{header.humanize}:\n" : ''
|
56
|
-
b += send("self_#{header}") + "\n"
|
57
|
-
definition.alternatives.each do |alternative|
|
58
|
-
b += IDENT + self.alternative(alternative) + "\n"
|
59
|
-
end
|
60
|
-
b
|
56
|
+
.reject(&:blank?).join(OPTION_DESCRIPTION_SEPARATOR)
|
61
57
|
end
|
62
58
|
|
59
|
+
# @return [String]
|
63
60
|
def options_section
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
list_section(
|
62
|
+
'Options',
|
63
|
+
definition.alternatives.flat_map(&:options).map { |option| option_definition(option) }
|
64
|
+
)
|
67
65
|
end
|
68
66
|
|
67
|
+
# @return [String]
|
69
68
|
def usage_section
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
list_section(
|
70
|
+
'Usage',
|
71
|
+
definition.alternatives.map { |alternative| self.alternative(alternative) }
|
72
|
+
)
|
74
73
|
end
|
75
74
|
|
76
75
|
def to_s
|
77
|
-
|
76
|
+
join_sections(definition.description, usage_section, options_section, *extra_sections)
|
78
77
|
end
|
79
78
|
end
|
80
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
|
@@ -6,7 +6,7 @@ require 'eac_ruby_utils/core_ext'
|
|
6
6
|
module EacCli
|
7
7
|
module RunnerWith
|
8
8
|
module Help
|
9
|
-
require_sub __FILE__,
|
9
|
+
require_sub __FILE__, require_mode: :kernel
|
10
10
|
common_concern do
|
11
11
|
include ::EacCli::Runner
|
12
12
|
|
@@ -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
|
|
@@ -27,10 +39,9 @@ module EacCli
|
|
27
39
|
raise ::EacCli::Runner::Exit
|
28
40
|
end
|
29
41
|
|
42
|
+
# @return [String]
|
30
43
|
def help_text
|
31
|
-
|
32
|
-
r += help_extra_text if respond_to?(:help_extra_text)
|
33
|
-
r
|
44
|
+
::EacCli::RunnerWith::Help::Builder.new(self).to_s
|
34
45
|
end
|
35
46
|
|
36
47
|
def show_help?
|
@@ -51,9 +51,9 @@ module EacCli
|
|
51
51
|
available_subcommands.keys.sort.join(', ')
|
52
52
|
end
|
53
53
|
|
54
|
+
# @return [Hash<String, Enumerable<String>]
|
54
55
|
def help_extra_text
|
55
|
-
(
|
56
|
-
.map { |v| "#{v}\n" }.join
|
56
|
+
help_list_section('Subcommands', available_subcommands.keys.sort)
|
57
57
|
end
|
58
58
|
|
59
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,6 +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
|
130
|
+
- lib/eac_cli/runner_with/help/layout.rb
|
129
131
|
- lib/eac_cli/runner_with/input.rb
|
130
132
|
- lib/eac_cli/runner_with/output.rb
|
131
133
|
- lib/eac_cli/runner_with/subcommands.rb
|