eac_cli 0.15.0 → 0.16.3

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: adea15fa71d63d7ee84ffd7978a582098b9e582a8ab32bdf2f332d1fc06abffa
4
- data.tar.gz: c8d7a4875e1d551a45e9cd6ad7dbdd26107ed296008ce068df3166a0a53d242a
3
+ metadata.gz: 30d359d444a24b0a8f618b39e2630c1272b8e7eb372c5785641f3a64931cff93
4
+ data.tar.gz: 0e1391a2382ead2b2d2e3d15d0fc036cfb88f6bde71dac7fdf14bcd633cd57bf
5
5
  SHA512:
6
- metadata.gz: f62270d724e15ef2ee006d0f74cf065b09a97bae467ce629c47b7e3a90a48131f1b0f555255215bf94ffe4576668ab060eda77c89cc8c119b2847b919690d6b7
7
- data.tar.gz: 30fec20cf4e1e3c121c943edee3044b8c636219e45434ea8f1847bccaee5d904d6980dcba9a48e228b4928923f24ad6acea43cb5c5615d6a86b4065f6f6aad32
6
+ metadata.gz: 0a2bb5941764c0c3172edec4468ec9c31c747eb6fdc899575504c43bd6354d361c33808af41b6dd6019e9c6331ffa2a96ec950bf71f33c0ec48d1c8433e7b194
7
+ data.tar.gz: bf0c7409ebb3db51fad860006e221730032da4c916d754fda5ace314f1a4d4f2894dbc3ad6a533584336cc039e6e775b09b746c74bd4f7aec79bb850ccb67224
@@ -28,7 +28,11 @@ module EacCli
28
28
  end
29
29
 
30
30
  def identifier
31
- long.to_s.variableize.to_sym
31
+ [long, short].each do |v|
32
+ v.to_s.if_present { |vv| return vv.variableize.to_sym }
33
+ end
34
+
35
+ raise 'No short or long option to build identifier'
32
36
  end
33
37
 
34
38
  def repeat?
@@ -36,7 +36,9 @@ module EacCli
36
36
  end
37
37
 
38
38
  def option_definition(option)
39
- self.class.option_usage_full(option) + OPTION_DESC_SEP + option.description
39
+ self.class.option_usage_full(option) + option.description.if_present('') do |v|
40
+ OPTION_DESC_SEP + v
41
+ end
40
42
  end
41
43
 
42
44
  def section(header, include_header = true)
@@ -14,7 +14,9 @@ module EacCli
14
14
  end
15
15
 
16
16
  def find_short_option(char)
17
- alternative.options.find { |option| short_without_prefix(option.short) == char }
17
+ alternative.options.find do |option|
18
+ short_without_prefix(option.short).if_present(false) { |v| v == char }
19
+ end
18
20
  end
19
21
 
20
22
  def short_option_collect_argv_value
@@ -37,7 +39,7 @@ module EacCli
37
39
  end
38
40
 
39
41
  def short_without_prefix(short)
40
- short.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
42
+ short.to_s.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
41
43
  end
42
44
  end
43
45
  end
@@ -27,8 +27,9 @@ module EacCli
27
27
 
28
28
  def parent_call(method_name, *args)
29
29
  return parent.context(method_name, *args) if parent.respond_to?(:context)
30
+ return parent.runner_context.call(method_name, *args) if parent.respond_to?(:runner_context)
30
31
 
31
- parent.runner_context.call(method_name, *args)
32
+ raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
32
33
  end
33
34
  end
34
35
  end
@@ -3,15 +3,22 @@
3
3
  module EacCli
4
4
  module Runner
5
5
  module InstanceMethods
6
+ PARSER_ERROR_EXIT_CODE = 1
7
+
6
8
  def run_run
7
9
  parsed
8
10
  run_callbacks(:run) { run }
9
11
  rescue ::EacCli::Parser::Error => e
10
- $stderr.write("#{e}\n")
12
+ run_parser_error(e)
11
13
  rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
12
14
  # Do nothing
13
15
  end
14
16
 
17
+ def run_parser_error(error)
18
+ $stderr.write("#{error}\n")
19
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
20
+ end
21
+
15
22
  def runner_context
16
23
  return @runner_context if @runner_context
17
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.15.0'
4
+ VERSION = '0.16.3'
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.15.0
4
+ version: 0.16.3
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: 2021-02-21 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -30,20 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.1.2
33
+ version: '0.2'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.1.2
40
+ version: '0.2'
47
41
  description:
48
42
  email:
49
43
  executables: []
@@ -87,7 +81,6 @@ files:
87
81
  - lib/eac_cli/runner/instance_methods.rb
88
82
  - lib/eac_cli/runner_with.rb
89
83
  - lib/eac_cli/runner_with/help.rb
90
- - lib/eac_cli/runner_with/output_file.rb
91
84
  - lib/eac_cli/runner_with/subcommands.rb
92
85
  - lib/eac_cli/runner_with_set.rb
93
86
  - lib/eac_cli/version.rb
@@ -109,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
102
  - !ruby/object:Gem::Version
110
103
  version: '0'
111
104
  requirements: []
112
- rubygems_version: 3.0.8
105
+ rubygems_version: 3.0.9
113
106
  signing_key:
114
107
  specification_version: 4
115
108
  summary: Utilities to build CLI applications with Ruby.
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
6
-
7
- module EacCli
8
- module RunnerWith
9
- module OutputFile
10
- common_concern do
11
- include ::EacCli::Runner
12
- include ::EacRubyUtils::AbstractMethods
13
-
14
- abstract_methods :output_content
15
-
16
- runner_definition do
17
- arg_opt '-o', '--output-file', 'Output to file.'
18
- end
19
- end
20
-
21
- def run_output
22
- if parsed.output_file.present?
23
- ::File.write(parsed.output_file, output_content)
24
- else
25
- $stdout.write(output_content)
26
- end
27
- end
28
- end
29
- end
30
- end