eac_cli 0.27.4 → 0.27.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf821288a53c84ca73558b565fd37131c0bc447dcefefdbd94cad83dc585b3b2
4
- data.tar.gz: 72432bbad929217ef65ef9a8283141dd9af19117ad7451a7fd165e9b2e72aa32
3
+ metadata.gz: 938ea5f13a60ee96410614ad3a2467e1ee172f0edbbf8a853169f0c563f61fc6
4
+ data.tar.gz: ac6f3fde9506adc953a59e96b8c152037233c7609e8194e65a70534dd2f2e358
5
5
  SHA512:
6
- metadata.gz: eef32945440aa2f30ed31247fe5ea287c5bace6ac511ad4f9b6327e7dd7da1c116fd6d2e40f9a304988b2965b765c860d1b10b893eaf0d0a5cf5ffb2bb404144
7
- data.tar.gz: a0690e698c2a702e770e57708bf8e59f115e2fc99d27afb5fbd435866bc6571463835fa5fb7ce1e86ff52eb4eb27f58ba23c0801c187d21b577fb8c2fa37c1b9
6
+ metadata.gz: fc0d1c69a1f274767b42dcd34456c004edf0896623c7791bc87e1d23fdfd92df65b5ce960e84c1341897b196ba4337de16d1c6e517966d0e6340e86059c2ff9c
7
+ data.tar.gz: f9dd8eb35bb94e9cdf58d78021ef07f7fea1a9437c57300085bc8a835505100bfaa582fdf7d1f76b97a5cf959d3266bd980a33a38e6f6511f6a0cd5b77be7fee
@@ -39,10 +39,6 @@ module EacCli
39
39
  self.description = description
40
40
  end
41
41
 
42
- def help_formatter
43
- @help_formatter ||= ::EacCli::Definition::HelpFormatter.new(self)
44
- end
45
-
46
42
  def main_alternative
47
43
  @main_alternative ||= begin
48
44
  r = ::EacCli::Definition::Alternative.new
@@ -7,18 +7,19 @@ module EacCli
7
7
  module Help
8
8
  class Builder
9
9
  class Alternative
10
- PROGRAM_MACRO = '__PROGRAM__'
10
+ enable_method_class
11
+
11
12
  SUBCOMMANDS_MACRO = '__SUBCOMMANDS__'
12
13
 
13
- common_constructor :alternative
14
+ common_constructor :builder, :alternative
14
15
 
15
- def to_s
16
+ def result
16
17
  (
17
- [PROGRAM_MACRO] +
18
+ program_name +
18
19
  alternative.options_argument?.if_present([]) { |_v| ['[options]'] } +
19
20
  options +
20
21
  positionals
21
- ).join(::EacCli::RunnerWith::Help::Builder::SEP)
22
+ ).join(builder.word_separator)
22
23
  end
23
24
 
24
25
  def options
@@ -49,6 +50,12 @@ module EacCli
49
50
  r
50
51
  end
51
52
  end
53
+
54
+ def program_name
55
+ r = builder.runner.program_name
56
+ r = [r] unless r.is_a?(::Enumerable)
57
+ r
58
+ end
52
59
  end
53
60
  end
54
61
  end
@@ -6,8 +6,8 @@ module EacCli
6
6
  module RunnerWith
7
7
  module Help
8
8
  class Builder
9
- require_sub __FILE__
10
- common_constructor :definition
9
+ require_sub __FILE__, require_dependency: true
10
+ common_constructor :runner
11
11
 
12
12
  SEP = ' '
13
13
  IDENT = SEP * 2
@@ -28,11 +28,21 @@ module EacCli
28
28
 
29
29
  def option_usage_full(option)
30
30
  if option.long.present?
31
- [option.short, option_long(option)].reject(&:blank?).join(SEP)
31
+ [option.short, option_long(option)].reject(&:blank?).join(word_separator)
32
32
  else
33
33
  option_short(option)
34
34
  end
35
35
  end
36
+
37
+ def word_separator
38
+ SEP
39
+ end
40
+ end
41
+
42
+ delegate :word_separator, to: :class
43
+
44
+ def definition
45
+ runner.class.runner_definition
36
46
  end
37
47
 
38
48
  def option_definition(option)
@@ -45,8 +55,7 @@ module EacCli
45
55
  b = include_header ? "#{header.humanize}:\n" : ''
46
56
  b += send("self_#{header}") + "\n"
47
57
  definition.alternatives.each do |alternative|
48
- b += IDENT + ::EacCli::RunnerWith::Help::Builder::Alternative.new(alternative).to_s +
49
- "\n"
58
+ b += IDENT + self.alternative(alternative) + "\n"
50
59
  end
51
60
  b
52
61
  end
@@ -60,7 +69,7 @@ module EacCli
60
69
  def usage_section
61
70
  "Usage:\n" +
62
71
  definition.alternatives.map do |alternative|
63
- IDENT + ::EacCli::RunnerWith::Help::Builder::Alternative.new(alternative).to_s + "\n"
72
+ IDENT + self.alternative(alternative) + "\n"
64
73
  end.join
65
74
  end
66
75
 
@@ -28,7 +28,7 @@ module EacCli
28
28
  end
29
29
 
30
30
  def help_text
31
- r = ::EacCli::RunnerWith::Help::Builder.new(self.class.runner_definition).to_s
31
+ r = ::EacCli::RunnerWith::Help::Builder.new(self).to_s
32
32
  r += help_extra_text if respond_to?(:help_extra_text)
33
33
  r
34
34
  end
@@ -104,7 +104,7 @@ module EacCli
104
104
  end
105
105
 
106
106
  def subcommand_program
107
- subcommand_name
107
+ [program_name, subcommand_name]
108
108
  end
109
109
 
110
110
  def subcommand_runner
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.27.4'
4
+ VERSION = '0.27.5'
5
5
  end
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.27.4
4
+ version: 0.27.5
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: 2022-06-19 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -86,7 +86,6 @@ files:
86
86
  - lib/eac_cli/definition/base_option.rb
87
87
  - lib/eac_cli/definition/base_option/initialize_args_parser.rb
88
88
  - lib/eac_cli/definition/boolean_option.rb
89
- - lib/eac_cli/definition/help_formatter.rb
90
89
  - lib/eac_cli/definition/positional_argument.rb
91
90
  - lib/eac_cli/enum.rb
92
91
  - lib/eac_cli/old_configs.rb
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/help/builder/alternative'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module EacCli
7
- class Definition
8
- class HelpFormatter
9
- SEP = ' '
10
- IDENT = SEP * 2
11
- OPTION_DESC_SEP = IDENT * 2
12
-
13
- class << self
14
- def option_long(option)
15
- b = option.long
16
- b += '=VALUE' if option.argument?
17
- b
18
- end
19
-
20
- def option_short(option)
21
- b = option.short
22
- b += 'VALUE' if option.argument?
23
- b
24
- end
25
- end
26
-
27
- common_constructor :definition
28
-
29
- def positional_argument(positional)
30
- if positional.subcommand?
31
- ::EacCli::RunnerWith::Help::Builder::Alternative::SUBCOMMANDS_MACRO
32
- else
33
- r = "<#{positional.name}>"
34
- r += '...' if positional.repeat?
35
- r = "[#{r}]" if positional.optional?
36
- r
37
- end
38
- end
39
-
40
- def section(header, include_header = true)
41
- b = include_header ? "#{header.humanize}:\n" : ''
42
- b += send("self_#{header}") + "\n"
43
- # TO-DO: implement alternatives
44
- b
45
- end
46
-
47
- def self_options
48
- definition.options.map { |option| IDENT + option_definition(option) }.join("\n")
49
- end
50
-
51
- def self_usage
52
- IDENT + self_usage_arguments.join(SEP)
53
- end
54
-
55
- def self_usage_arguments
56
- [::EacCli::RunnerWith::Help::Builder::Alternative::PROGRAM_MACRO] +
57
- definition.options_argument.if_present([]) { |_v| ['[options]'] } +
58
- self_usage_arguments_options +
59
- self_usage_arguments_positional
60
- end
61
-
62
- def self_usage_arguments_options
63
- definition.options.select(&:show_on_usage?).map do |option|
64
- self.class.option_long(option)
65
- end
66
- end
67
-
68
- def self_usage_arguments_positional
69
- definition.positional.map { |p| positional_argument(p) }
70
- end
71
-
72
- def to_banner
73
- "#{definition.description}\n\n#{section('usage')}"
74
- end
75
- end
76
- end
77
- end