eac_cli 0.27.3 → 0.27.4

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: 13923176efdc8317f5f39295cb3e11e4735d66e7997580af8a5f3c8f2f0c03f4
4
- data.tar.gz: 2f9edad2f2ea7484c88e9948f6c5ff47635b13ddfc2809fa2af481ebd0c347c9
3
+ metadata.gz: cf821288a53c84ca73558b565fd37131c0bc447dcefefdbd94cad83dc585b3b2
4
+ data.tar.gz: 72432bbad929217ef65ef9a8283141dd9af19117ad7451a7fd165e9b2e72aa32
5
5
  SHA512:
6
- metadata.gz: '0918b4794d0ced61971d2f308bb92a731b2c70130774a4e3b68db807fcb94e4a3addaa78488b1a1ab4a38e76557f1bf7fd0a1b5198dc545eefbeecfc5db5b593'
7
- data.tar.gz: 6feb7e12b85ded5683858a2943390f95f092b79b4023f193c3792f24d3ed6e6294ea111f82c667c65dce50ccb005abea0c5db8233dadc6736442ab21c548c75f
6
+ metadata.gz: eef32945440aa2f30ed31247fe5ea287c5bace6ac511ad4f9b6327e7dd7da1c116fd6d2e40f9a304988b2965b765c860d1b10b893eaf0d0a5cf5ffb2bb404144
7
+ data.tar.gz: a0690e698c2a702e770e57708bf8e59f115e2fc99d27afb5fbd435866bc6571463835fa5fb7ce1e86ff52eb4eb27f58ba23c0801c187d21b577fb8c2fa37c1b9
@@ -33,7 +33,7 @@ module EacCli
33
33
  # @return [EacCli::Definition::BaseOption] The option collected.
34
34
  def short_option_collect_char(char)
35
35
  option = find_short_option(char)
36
- raise_error "Invalid short option \"#{char}\"" unless option
36
+ raise_argv_current_invalid_option unless option
37
37
 
38
38
  option_collect_option(option)
39
39
  end
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/speaker'
4
- require 'eac_ruby_utils/speaker'
3
+ require 'eac_cli/definition'
4
+ require 'eac_cli/runner/class_runner'
5
5
 
6
6
  module EacCli
7
7
  module Runner
8
8
  module AfterClassMethods
9
+ # @return [EacCli::Runner::ClassRunner]
10
+ def class_runner(runner_context_args)
11
+ ::EacCli::Runner::ClassRunner.new(self, runner_context_args)
12
+ end
13
+
9
14
  def create(*runner_context_args)
10
- r = new
11
- r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
12
- r
15
+ class_runner(runner_context_args).create
13
16
  end
14
17
 
15
18
  def run(*runner_context_args)
16
- on_asserted_speaker do
17
- r = create(*runner_context_args)
18
- r.run_run
19
- r
20
- end
19
+ class_runner(runner_context_args).run
21
20
  end
22
21
 
23
22
  def runner_definition(&block)
@@ -29,18 +28,6 @@ module EacCli
29
28
  def super_runner_definition
30
29
  superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
31
30
  end
32
-
33
- private
34
-
35
- def on_asserted_speaker
36
- if ::EacRubyUtils::Speaker.context.optional_current
37
- yield
38
- else
39
- ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new) do
40
- yield
41
- end
42
- end
43
- end
44
31
  end
45
32
  end
46
33
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/speaker'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/speaker'
6
+
7
+ module EacCli
8
+ module Runner
9
+ class ClassRunner
10
+ PARSER_ERROR_EXIT_CODE = 1
11
+
12
+ common_constructor :klass, :context_args
13
+
14
+ def create
15
+ r = klass.new
16
+ r.runner_context = ::EacCli::Runner::Context.new(r, *context_args)
17
+ r
18
+ end
19
+
20
+ def run
21
+ on_asserted_speaker do
22
+ r = create
23
+ begin
24
+ r.run_run
25
+ rescue ::EacCli::Parser::Error => e
26
+ run_parser_error(r, e)
27
+ end
28
+ r
29
+ end
30
+ end
31
+
32
+ def run_parser_error(runner_instance, error)
33
+ $stderr.write("#{runner_instance.program_name}: #{error}\n")
34
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
35
+ end
36
+
37
+ private
38
+
39
+ def on_asserted_speaker
40
+ if ::EacRubyUtils::Speaker.context.optional_current
41
+ yield
42
+ else
43
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new) do
44
+ yield
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -3,22 +3,13 @@
3
3
  module EacCli
4
4
  module Runner
5
5
  module InstanceMethods
6
- PARSER_ERROR_EXIT_CODE = 1
7
-
8
6
  def run_run
9
7
  parsed
10
8
  run_callbacks(:run) { run }
11
- rescue ::EacCli::Parser::Error => e
12
- run_parser_error(e)
13
9
  rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
14
10
  # Do nothing
15
11
  end
16
12
 
17
- def run_parser_error(error)
18
- $stderr.write("#{program_name}: #{error}\n")
19
- ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
20
- end
21
-
22
13
  def runner_context
23
14
  return @runner_context if @runner_context
24
15
 
@@ -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_dependency: true
10
10
  common_concern do
11
11
  include ::EacCli::Runner
12
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.27.3'
4
+ VERSION = '0.27.4'
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.3
4
+ version: 0.27.4
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-04 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.83'
47
+ version: '0.95'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.83'
54
+ version: '0.95'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: eac_ruby_gem_support
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/eac_cli/rspec/setup.rb
113
113
  - lib/eac_cli/runner.rb
114
114
  - lib/eac_cli/runner/after_class_methods.rb
115
+ - lib/eac_cli/runner/class_runner.rb
115
116
  - lib/eac_cli/runner/context.rb
116
117
  - lib/eac_cli/runner/exit.rb
117
118
  - lib/eac_cli/runner/instance_methods.rb