avm-tools 0.117.1 → 0.117.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c5b9e1cd2e14d276b38a0efe3965a884143065eafbade65938f37f72f0857e9
4
- data.tar.gz: 81d047244f7fa7478bffc26e23457da9da5cc7e33839b6108e7fe55cb78a4706
3
+ metadata.gz: 35fb18a5736eb65f686b0915a77da3f4e548a64b0ce7e0bd5bc754483c675757
4
+ data.tar.gz: 053eeec2795b4cf08660991b06d13127e1a66b112a084642f8213fbe89a82e59
5
5
  SHA512:
6
- metadata.gz: 4c802171d7c42fde415e6674888a0d430c003107d87846e7159cfc5aebb7d04a604b7b7f6c034b9d0081206e111f373e13e7fada07e2130d92624409f4389b17
7
- data.tar.gz: 30765546f1f0faab035133812dd4f0508ac5a63112e2aa1925758c1bf66e7a81d92e01ed61f298c9f05f12cd156d49940d333c89ce3f9971b40021ef9c566bfd
6
+ metadata.gz: 356218e0b80f21fbd6612ef6f88b49112ee7d97bff1c7b3ef21039964f024dffbcf0944d4ab01b82c6f919384b0bba401319572911599154a418f8a1e3d50c99
7
+ data.tar.gz: f290a18803f13ae99202ec10ee6106f267913a27b8537dd2fc3f6156151b6d0f01a34354c980de17885b85dc7614019adb7747c03e91ebe1038aca22c6d898a5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.117.1'
5
+ VERSION = '0.117.2'
6
6
  end
7
7
  end
@@ -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
@@ -26,7 +26,7 @@ RSpec.describe ::EacCli::RunnerWith::Help do
26
26
  ].each do |runner_argv|
27
27
  context "when runner ARGV is #{runner_argv}" do
28
28
  let(:instance) { runner.create(argv: runner_argv) }
29
- let(:expected_output) do
29
+ let(:expected_output_source) do
30
30
  <<~OUTPUT
31
31
  A stub runner.
32
32
 
@@ -39,6 +39,9 @@ RSpec.describe ::EacCli::RunnerWith::Help do
39
39
 
40
40
  OUTPUT
41
41
  end
42
+ let(:expected_output) do
43
+ expected_output_source.gsub('__PROGRAM__', instance.program_name)
44
+ end
42
45
 
43
46
  it 'show help text' do
44
47
  expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
@@ -57,7 +57,7 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
57
57
 
58
58
  context 'with help' do
59
59
  let(:instance) { parent_runner.create(%w[--help]) }
60
- let(:expected_output) do
60
+ let(:expected_output_source) do
61
61
  <<~OUTPUT
62
62
  A stub root runner.
63
63
 
@@ -73,6 +73,9 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
73
73
  child-cmd
74
74
  OUTPUT
75
75
  end
76
+ let(:expected_output) do
77
+ expected_output_source.gsub('__PROGRAM__', instance.program_name)
78
+ end
76
79
 
77
80
  before do
78
81
  parent_runner.include(::EacCli::RunnerWith::Help)
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'eac_cli', '~> 0.27', '>= 0.27.4'
15
+ s.add_dependency 'eac_cli', '~> 0.27', '>= 0.27.5'
16
16
  s.add_dependency 'eac_fs', '~> 0.10'
17
17
  s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.6'
18
18
  s.add_dependency 'eac_ruby_utils', '~> 0.95', '>= 0.95.1'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.16.3'
4
+ VERSION = '0.16.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.117.1
4
+ version: 0.117.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
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: aranha-parsers
@@ -197,7 +197,7 @@ dependencies:
197
197
  version: '0.16'
198
198
  - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: 0.16.3
200
+ version: 0.16.4
201
201
  type: :runtime
202
202
  prerelease: false
203
203
  version_requirements: !ruby/object:Gem::Requirement
@@ -207,7 +207,7 @@ dependencies:
207
207
  version: '0.16'
208
208
  - - ">="
209
209
  - !ruby/object:Gem::Version
210
- version: 0.16.3
210
+ version: 0.16.4
211
211
  - !ruby/object:Gem::Dependency
212
212
  name: eac_ruby_gems_utils
213
213
  requirement: !ruby/object:Gem::Requirement
@@ -806,7 +806,6 @@ files:
806
806
  - sub/eac_cli/lib/eac_cli/definition/base_option.rb
807
807
  - sub/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb
808
808
  - sub/eac_cli/lib/eac_cli/definition/boolean_option.rb
809
- - sub/eac_cli/lib/eac_cli/definition/help_formatter.rb
810
809
  - sub/eac_cli/lib/eac_cli/definition/positional_argument.rb
811
810
  - sub/eac_cli/lib/eac_cli/enum.rb
812
811
  - sub/eac_cli/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