eac_tools 0.81.0 → 0.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +10 -10
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +2 -2
  5. data/sub/avm/lib/avm/sources/base/sub/remove.rb +38 -0
  6. data/sub/avm/lib/avm/sources/base/sub.rb +26 -0
  7. data/sub/avm/lib/avm/sources/base/subs.rb +7 -0
  8. data/sub/avm/lib/avm/version.rb +1 -1
  9. data/sub/avm/locale/en.yml +6 -0
  10. data/sub/avm/locale/pt-BR.yml +6 -0
  11. data/sub/avm-tools/avm-tools.gemspec +1 -1
  12. data/sub/avm-tools/lib/avm/tools/runner/source/sub/remove.rb +22 -0
  13. data/sub/avm-tools/lib/avm/tools/runner/source/sub.rb +29 -0
  14. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  15. data/sub/eac_cli/eac_cli.gemspec +2 -2
  16. data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +4 -4
  17. data/sub/eac_cli/lib/eac_cli/definition/argument_option.rb +2 -2
  18. data/sub/eac_cli/lib/eac_cli/definition/boolean_option.rb +3 -4
  19. data/sub/eac_cli/lib/eac_cli/definition/{base_option → option}/initialize_args_parser.rb +1 -1
  20. data/sub/eac_cli/lib/eac_cli/definition/option.rb +73 -0
  21. data/sub/eac_cli/lib/eac_cli/definition/option_or_positional.rb +43 -0
  22. data/sub/eac_cli/lib/eac_cli/definition/{positional_argument.rb → positional.rb} +14 -22
  23. data/sub/eac_cli/lib/eac_cli/definition.rb +17 -3
  24. data/sub/eac_cli/lib/eac_cli/parser/alternative/argv.rb +2 -0
  25. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +10 -1
  26. data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +20 -0
  27. data/sub/eac_cli/lib/eac_cli/parser/collector.rb +10 -1
  28. data/sub/eac_cli/lib/eac_cli/rspec.rb +1 -1
  29. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +1 -1
  30. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  31. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative/subcommands_spec.rb +58 -0
  32. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +1 -52
  33. data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +3 -3
  34. data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +2 -2
  35. metadata +17 -10
  36. data/sub/eac_cli/lib/eac_cli/definition/base_option.rb +0 -68
  37. data/sub/eac_cli/lib/eac_cli/definition/default_value.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d2e685c6164fa7bbf8b6c8aff6f6b893482bb469306379210cc7d54d8ea3f05
4
- data.tar.gz: acedb29f75ec68d89fe776ea05976050519ec549f9f328f4de56835109c32710
3
+ metadata.gz: 708d42ba52d2d044676786c93ad0213f7ace3709a8c7463232283ed38fb65fd7
4
+ data.tar.gz: 8258727a71e6eecb3f2bb4d9513381bec6303e405bfd35e49ddcd193d26d0a4b
5
5
  SHA512:
6
- metadata.gz: eb5a6a90e7655ac953173526517d7de438f76f25d8f11f9ecc0a64d013d260311cb8779595a773416e22dd3fc6fbf01f0002eefbcaf7eaf0df874c38e140b186
7
- data.tar.gz: 45a9f8b13ac0a309fe00568f4ee4911a84eb9d8a9caaac14c3412c02f489d8802ce82362e2c4fd9e742e260d2bf5cfc56e61e05010f833e8bb327a1d7b87aee3
6
+ metadata.gz: 01442d1e31829b644915a656db3c53c33643fff0706a2cc2848ef72abf95370049b6d98d5128739679b30fd8692cff897bf42c9fe164e2a088f5912343d9b48d
7
+ data.tar.gz: 6a2bd15e0ce916d2f99d0cb71048efadda6961d373614df80b04fce683ff89b522e402683a8533c966fa7e2b0b6278eaed2b02af621c4c2877be8bdefc3ee02d
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.81.0)
5
- avm (~> 0.82)
4
+ eac_tools (0.82.0)
5
+ avm (~> 0.83)
6
6
  avm-eac_asciidoctor_base0 (~> 0.19)
7
7
  avm-eac_generic_base0 (~> 0.12, >= 0.12.1)
8
8
  avm-eac_github_base0 (~> 0.3)
@@ -18,7 +18,7 @@ PATH
18
18
  avm-eac_webapp_base0 (~> 0.18, >= 0.18.2)
19
19
  avm-eac_wordpress_base0 (~> 0.3, >= 0.3.1)
20
20
  avm-git (~> 0.14)
21
- avm-tools (~> 0.158)
21
+ avm-tools (~> 0.159)
22
22
  eac_ruby_utils (~> 0.119, >= 0.119.2)
23
23
 
24
24
  PATH
@@ -180,9 +180,9 @@ PATH
180
180
  PATH
181
181
  remote: sub/avm-tools
182
182
  specs:
183
- avm-tools (0.158.0)
183
+ avm-tools (0.159.0)
184
184
  aranha-parsers (~> 0.21)
185
- avm (~> 0.82)
185
+ avm (~> 0.83)
186
186
  avm-eac_ruby_base1 (~> 0.33)
187
187
  avm-eac_ubuntu_base0 (~> 0.5)
188
188
  avm-files (~> 0.6, >= 0.6.2)
@@ -198,9 +198,9 @@ PATH
198
198
  PATH
199
199
  remote: sub/avm
200
200
  specs:
201
- avm (0.82.0)
201
+ avm (0.83.0)
202
202
  aranha-parsers (~> 0.21)
203
- eac_cli (~> 0.38)
203
+ eac_cli (~> 0.38, >= 0.38.1)
204
204
  eac_config (~> 0.14, >= 0.14.1)
205
205
  eac_docker (~> 0.7)
206
206
  eac_fs (~> 0.16)
@@ -214,9 +214,9 @@ PATH
214
214
  PATH
215
215
  remote: sub/eac_cli
216
216
  specs:
217
- eac_cli (0.38.0)
217
+ eac_cli (0.38.1)
218
218
  colorize (~> 0.8, >= 0.8.1)
219
- eac_config (~> 0.14)
219
+ eac_config (~> 0.14, >= 0.14.1)
220
220
  eac_ruby_utils (~> 0.119, >= 0.119.2)
221
221
 
222
222
  PATH
@@ -253,7 +253,7 @@ GEM
253
253
  ofx-parser (~> 1.1)
254
254
  asciidoctor (2.0.20)
255
255
  ast (2.4.2)
256
- base64 (0.1.1)
256
+ base64 (0.2.0)
257
257
  clipboard (1.3.6)
258
258
  colorize (0.8.1)
259
259
  concurrent-ruby (1.2.2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.81.0'
4
+ VERSION = '0.82.0'
5
5
  end
data/sub/avm/avm.gemspec CHANGED
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.authors = ['Eduardo H. Bogoni']
11
11
  s.summary = 'Ruby base library for Agora Vai! Methodology (https://avm.esquiloazul.tech).'
12
12
 
13
- s.files = Dir['{lib}/**/*']
13
+ s.files = Dir['{lib, locale}/**/*']
14
14
 
15
15
  s.add_dependency 'aranha-parsers', '~> 0.21'
16
- s.add_dependency 'eac_cli', '~> 0.38'
16
+ s.add_dependency 'eac_cli', '~> 0.38', '>= 0.38.1'
17
17
  s.add_dependency 'eac_config', '~> 0.14', '>= 0.14.1'
18
18
  s.add_dependency 'eac_docker', '~> 0.7'
19
19
  s.add_dependency 'eac_fs', '~> 0.16'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ class Sub
9
+ class Remove
10
+ acts_as_instance_method
11
+
12
+ # !method initialize(sub)
13
+ # @param sub [Avm::Sources::Base::Sub]
14
+ common_constructor :sub
15
+ delegate :source, to: :sub
16
+
17
+ # @return [void]
18
+ def result
19
+ source.scm.commit_if_change(commit_message) { do_changes }
20
+ end
21
+
22
+ private
23
+
24
+ # @return [String]
25
+ def commit_message
26
+ sub.i18n_translate(:remove_commit_message, sub_path: sub.sub_path)
27
+ end
28
+
29
+ # @return [void]
30
+ def do_changes
31
+ ::FileUtils.rm_rf(sub.absolute_path)
32
+ source.on_sub_updated
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/base/subs_paths'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ class Sub
10
+ # !method initialize(source, sub_path)
11
+ # @param source [Avm::Sources::Base]
12
+ # @param sub_path [Pathname]
13
+ common_constructor :source, :sub_path do
14
+ self.sub_path = sub_path.to_pathname
15
+ end
16
+
17
+ # @return [Pathname]
18
+ def absolute_path
19
+ sub_path.expand_path(source.path)
20
+ end
21
+
22
+ require_sub __FILE__, require_mode: :kernel
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/sources/base/sub'
3
4
  require 'avm/sources/base/subs_paths'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
@@ -17,6 +18,12 @@ module Avm
17
18
  subs.lazy.map { |sub| path.expand_path.child_of?(sub.path) ? sub : nil }.find(&:present?)
18
19
  end
19
20
 
21
+ # @param sub_path [Pathname]
22
+ # @return [Avm::Sources::Base::Sub]
23
+ def sub(sub_path)
24
+ ::Avm::Sources::Base::Sub.new(self, sub_path)
25
+ end
26
+
20
27
  # @return [Enumerable<Avm::Sources::Base>]
21
28
  def subs
22
29
  subs_paths_to_search
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.82.0'
4
+ VERSION = '0.83.0'
5
5
  end
@@ -0,0 +1,6 @@
1
+ en:
2
+ avm:
3
+ sources:
4
+ base:
5
+ sub:
6
+ remove_commit_message: 'Sub[%{sub_path}]: remove.'
@@ -0,0 +1,6 @@
1
+ pt-BR:
2
+ avm:
3
+ sources:
4
+ base:
5
+ sub:
6
+ remove_commit_message: 'Sub[%{sub_path}]: remove.'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.required_ruby_version = '>= 2.7.0'
18
18
 
19
19
  s.add_dependency 'aranha-parsers', '~> 0.21'
20
- s.add_dependency 'avm', '~> 0.82'
20
+ s.add_dependency 'avm', '~> 0.83'
21
21
  s.add_dependency 'avm-eac_ruby_base1', '~> 0.33'
22
22
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.5'
23
23
  s.add_dependency 'avm-files', '~> 0.6', '>= 0.6.2'
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/tools/core_ext'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class Source < ::Avm::Sources::Runner
9
+ class Sub
10
+ class Remove
11
+ runner_with :help
12
+
13
+ def run
14
+ source_sub.remove
15
+ success "Sub[#{source_sub.sub_path}] removed"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/tools/core_ext'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class Source < ::Avm::Sources::Runner
9
+ class Sub
10
+ runner_with :help, :subcommands do
11
+ pos_arg :sub_path
12
+ subcommands
13
+ end
14
+ for_context :source_sub
15
+
16
+ private
17
+
18
+ # !method source_sub
19
+ # @return [Avm::Sources::Base::Sub]
20
+ def source_sub_uncached
21
+ source.sub(parsed.sub_path)
22
+ end
23
+
24
+ require_sub __FILE__
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.158.0'
5
+ VERSION = '0.159.0'
6
6
  end
7
7
  end
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  s.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
18
- s.add_dependency 'eac_config', '~> 0.14'
18
+ s.add_dependency 'eac_config', '~> 0.14', '>= 0.14.1'
19
19
  s.add_dependency 'eac_ruby_utils', '~> 0.119', '>= 0.119.2'
20
20
 
21
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.8.1'
21
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.9'
22
22
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/definition/argument_option'
4
4
  require 'eac_cli/definition/boolean_option'
5
- require 'eac_cli/definition/positional_argument'
5
+ require 'eac_cli/definition/positional'
6
6
 
7
7
  module EacCli
8
8
  class Definition
@@ -54,7 +54,7 @@ module EacCli
54
54
  end
55
55
 
56
56
  def pos_arg(name, arg_options = {})
57
- new_pos_arg = ::EacCli::Definition::PositionalArgument.new(name, arg_options)
57
+ new_pos_arg = ::EacCli::Definition::Positional.new(name, arg_options)
58
58
  check_positional_blocked(new_pos_arg)
59
59
  pos_set << new_pos_arg
60
60
  end
@@ -76,8 +76,8 @@ module EacCli
76
76
 
77
77
  def subcommands
78
78
  pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
79
- pos_set << ::EacCli::Definition::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
80
- optional: true, repeat: true)
79
+ pos_set << ::EacCli::Definition::Positional.new(SUBCOMMAND_ARGS_ARG,
80
+ optional: true, repeat: true)
81
81
  end
82
82
 
83
83
  def subcommands?
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/definition/base_option'
3
+ require 'eac_cli/definition/option'
4
4
 
5
5
  module EacCli
6
6
  class Definition
7
- class ArgumentOption < ::EacCli::Definition::BaseOption
7
+ class ArgumentOption < ::EacCli::Definition::Option
8
8
  def argument?
9
9
  true
10
10
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/definition/base_option'
3
+ require 'eac_cli/definition/option'
4
4
 
5
5
  module EacCli
6
6
  class Definition
7
- class BooleanOption < ::EacCli::Definition::BaseOption
7
+ class BooleanOption < ::EacCli::Definition::Option
8
8
  def argument?
9
9
  false
10
10
  end
@@ -16,8 +16,7 @@ module EacCli
16
16
  def default_value
17
17
  return super unless default_value?
18
18
 
19
- raise(::EacCli::Definition::Error,
20
- "Unallowed default value for boolean options (Option: #{self})")
19
+ raise("Unallowed default value for boolean options (Option: #{self})")
21
20
  end
22
21
 
23
22
  def default_default_value
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EacCli
4
4
  class Definition
5
- class BaseOption
5
+ class Option
6
6
  class InitializeArgsParser
7
7
  PROPERTIES = %i[short long description options].freeze
8
8
  attr_reader(*PROPERTIES)
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/option_or_positional'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ class Definition
8
+ # @abstract
9
+ class Option < ::EacCli::Definition::OptionOrPositional
10
+ require_sub __FILE__
11
+
12
+ class << self
13
+ # @param args [Enumerable<String>]
14
+ # @return [EacCli::Definition::Option]
15
+ def from_args(args)
16
+ p = ::EacCli::Definition::Option::InitializeArgsParser.new(args)
17
+ new(p.short, p.long, p.description, p.options)
18
+ end
19
+ end
20
+
21
+ DEFAULT_REQUIRED = false
22
+
23
+ enable_abstract_methods
24
+ lists.add_symbol :option, *OPTION_LIST, :default, :usage
25
+
26
+ # @!method initialize(short, long, description, options = {})
27
+ # @param short [String]
28
+ # @param long [String]
29
+ # @param description [String]
30
+ # @param options [Hash<Symbol, Object>]
31
+ # @raise [EacCli::Definition::Error]
32
+ common_constructor :short, :long, :description, :options, default: [{}] do
33
+ validate
34
+ self.options = ::EacCli::Definition::Option.lists.option.hash_keys_validate!(
35
+ options.symbolize_keys
36
+ )
37
+ end
38
+
39
+ # @return [Object]
40
+ def default_value
41
+ default_value? ? options[OPTION_DEFAULT] : default_default_value
42
+ end
43
+
44
+ # @return [Boolean]
45
+ def default_value?
46
+ options.key?(OPTION_DEFAULT)
47
+ end
48
+
49
+ # @return [Symbol]
50
+ # @raise [EacCli::Definition::Error] If no short or long option is provided.
51
+ def identifier
52
+ [long, short].each do |v|
53
+ v.to_s.if_present { |vv| return vv.variableize.to_sym }
54
+ end
55
+
56
+ raise('No short or long option to build identifier')
57
+ end
58
+
59
+ # @return [Boolean]
60
+ def show_on_usage?
61
+ options[:usage]
62
+ end
63
+
64
+ private
65
+
66
+ # @return [void]
67
+ # @raise [EacCli::Definition::Error]
68
+ def validate
69
+ raise 'Nor short neither long selector was set' if short.blank? && long.blank?
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Definition
7
+ # @abstract
8
+ class OptionOrPositional
9
+ acts_as_abstract :build_value, :default_value, :identifier, :options
10
+ enable_listable
11
+
12
+ OPTION_LIST = %i[optional repeat required].freeze
13
+
14
+ # @return [Boolean]
15
+ def optional?
16
+ !required?
17
+ end
18
+
19
+ # @raise [EacCli::Definition::Error]
20
+ def raise(*args)
21
+ ::Kernel.raise ::EacCli::Definition::Error, *args
22
+ end
23
+
24
+ # @return [Boolean]
25
+ def repeat?
26
+ options[:repeat] ? true : false
27
+ end
28
+
29
+ # @return [Boolean]
30
+ def required?
31
+ return true if options.key?(:required) && options.fetch(:required)
32
+ return false if options.key?(:optional) && options.fetch(:optional)
33
+
34
+ self.class.const_get('DEFAULT_REQUIRED')
35
+ end
36
+
37
+ # @return [String]
38
+ def to_s
39
+ "#{self.class.name.demodulize}[#{identifier}]"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,19 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/definition/option_or_positional'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module EacCli
6
7
  class Definition
7
- class PositionalArgument
8
+ class Positional < ::EacCli::Definition::OptionOrPositional
8
9
  DEFAULT_REQUIRED = true
9
10
  DEFAULT_VISIBLE = true
10
11
 
11
- enable_listable
12
- lists.add_symbol :option, :optional, :repeat, :required, :subcommand, :visible
12
+ lists.add_symbol :option, *OPTION_LIST, :subcommand, :visible
13
+
14
+ # @!method initialize(name, options = {})
15
+ # @param name [String]
16
+ # @param options [Hash<Symbol, Object>]
13
17
  common_constructor :name, :options, default: [{}] do
14
18
  options.assert_valid_keys(self.class.lists.option.values)
15
19
  end
16
20
 
21
+ # @param new_value [Array, Object]
22
+ # @param previous_value [Array, Object]
23
+ # @return [Array]
17
24
  def build_value(new_value, previous_value)
18
25
  if previous_value.is_a?(::Array)
19
26
  previous_value + [new_value]
@@ -22,37 +29,22 @@ module EacCli
22
29
  end
23
30
  end
24
31
 
32
+ # @return [Object]
25
33
  def default_value
26
34
  repeat? ? [] : nil
27
35
  end
28
36
 
37
+ # @return [Symbol]
29
38
  def identifier
30
39
  name.to_s.variableize.to_sym
31
40
  end
32
41
 
33
- def optional?
34
- !required?
35
- end
36
-
37
- def repeat?
38
- options[OPTION_REPEAT]
39
- end
40
-
41
- def required?
42
- return true if options.key?(OPTION_REQUIRED) && options.fetch(OPTION_REQUIRED)
43
- return false if options.key?(OPTION_OPTIONAL) && options.fetch(OPTION_OPTIONAL)
44
-
45
- DEFAULT_REQUIRED
46
- end
47
-
42
+ # @return [Boolean]
48
43
  def subcommand?
49
44
  options[OPTION_SUBCOMMAND]
50
45
  end
51
46
 
52
- def to_s
53
- "#{self.class.name.demodulize}[#{identifier}]"
54
- end
55
-
47
+ # @return [Boolean]
56
48
  def visible?
57
49
  options.key?(OPTION_VISIBLE) ? options.fetch(OPTION_VISIBLE) : DEFAULT_VISIBLE
58
50
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/definition/argument_option'
4
4
  require 'eac_cli/definition/boolean_option'
5
- require 'eac_cli/definition/positional_argument'
5
+ require 'eac_cli/definition/positional'
6
6
  require 'eac_ruby_utils/core_ext'
7
7
 
8
8
  module EacCli
@@ -13,6 +13,7 @@ module EacCli
13
13
  SUBCOMMAND_NAME_ARG = 'subcommand'
14
14
  SUBCOMMAND_ARGS_ARG = 'subcommand_args'
15
15
 
16
+ # @return [String, nil]
16
17
  attr_accessor :description
17
18
 
18
19
  def initialize
@@ -20,25 +21,35 @@ module EacCli
20
21
  alternatives_set[MAIN_ALTERNATIVE_KEY] = main_alternative
21
22
  end
22
23
 
23
- def alt(&block)
24
+ # @return [EacCli::Definition::Alternative]
25
+ def alt(key = nil, &block)
26
+ key ||= new_alternative_key
27
+ raise(::EacCli::Definition::Error, "A alternative with key=\"#{key}\" already exists") if
28
+ key.present? && alternatives_set.key?(key)
29
+
24
30
  r = ::EacCli::Definition::Alternative.new
25
31
  r.instance_eval(&block)
26
- alternatives_set[new_alternative_key] = r
32
+ alternatives_set[key] = r
27
33
  r
28
34
  end
29
35
 
36
+ # @return [Enumerable<EacCli::Definition::Alternative>]
30
37
  def alternatives
31
38
  alternatives_set.values
32
39
  end
33
40
 
41
+ # @return [EacCli::Definition::Alternative]
42
+ # @raise [KeyError] If there is not a alternative with provided key.
34
43
  def alternative(key)
35
44
  alternatives_set.fetch(key)
36
45
  end
37
46
 
47
+ # Same as {#description=}.
38
48
  def desc(description)
39
49
  self.description = description
40
50
  end
41
51
 
52
+ # @return [EacCli::Definition::Alternative]
42
53
  def main_alternative
43
54
  @main_alternative ||= begin
44
55
  r = ::EacCli::Definition::Alternative.new
@@ -47,10 +58,13 @@ module EacCli
47
58
  end
48
59
  end
49
60
 
61
+ # Same as {#options_argument=}.
62
+ # @param options_argument [Boolean]
50
63
  def options_arg(options_argument)
51
64
  self.options_argument = options_argument
52
65
  end
53
66
 
67
+ # @return [Boolean]
54
68
  def options_argument
55
69
  main_alternative.options_argument?
56
70
  end
@@ -4,10 +4,12 @@ module EacCli
4
4
  class Parser
5
5
  class Alternative
6
6
  module Argv
7
+ # @return [Enumerator<String>]
7
8
  def argv_enum
8
9
  @argv_enum ||= argv.each
9
10
  end
10
11
 
12
+ # @return [Boolean]
11
13
  def argv_pending?
12
14
  argv_enum.ongoing?
13
15
  end
@@ -5,23 +5,29 @@ module EacCli
5
5
  class Alternative
6
6
  module ShortOptions
7
7
  SHORT_OPTION_PREFIX = '-'
8
+ SHORT_OPTION_CHAR_PATTERN = /\A[0-9a-zA-Z]\z/.freeze
8
9
 
9
10
  private
10
11
 
12
+ # @return [Boolean]
11
13
  def argv_current_short_option?
12
14
  phase == PHASE_ANY && argv_enum.peek.start_with?(SHORT_OPTION_PREFIX) &&
13
15
  !argv_current_long_option?
14
16
  end
15
17
 
18
+ # @para char [String]
19
+ # @return [EacCli::Definition::Option, nil]
16
20
  def find_short_option(char)
17
21
  alternative.options.find do |option|
18
22
  short_without_prefix(option.short).if_present(false) { |v| v == char }
19
23
  end
20
24
  end
21
25
 
26
+ # @return [void]
22
27
  def short_option_collect_argv_value
23
28
  last_option = nil
24
29
  short_without_prefix(argv_enum.peek).each_char do |char|
30
+ raise_error "Invalid option: \"#{char}\"" unless SHORT_OPTION_CHAR_PATTERN.match?(char)
25
31
  raise_error "Option \"#{last_option}\" requires a argument not provided" if
26
32
  last_option.present?
27
33
 
@@ -30,12 +36,15 @@ module EacCli
30
36
  end
31
37
  end
32
38
 
33
- # @return [EacCli::Definition::BaseOption] The option collected.
39
+ # @param char [String]
40
+ # @return [EacCli::Definition::Option] The option collected.
34
41
  def short_option_collect_char(char)
35
42
  option = find_short_option(char)
36
43
  option ? option_collect_option(option) : any_option_collect_option
37
44
  end
38
45
 
46
+ # @param short [String]
47
+ # @return [String]
39
48
  def short_without_prefix(short)
40
49
  short.to_s.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
41
50
  end
@@ -10,30 +10,40 @@ module EacCli
10
10
  require_sub __FILE__, include_modules: true
11
11
  enable_listable
12
12
  lists.add_symbol :phase, :any, :option_argument, :positional
13
+
14
+ # @return [EacCli::Parser::Error, nil]
13
15
  attr_reader :error
14
16
 
17
+ # @!method initialize(alternative, argv)
18
+ # @param alternative [EacCli::Definition::Alternative]
19
+ # @param argv [Array<String>]
15
20
  common_constructor :alternative, :argv do
16
21
  alternative.assert_argument(::EacCli::Definition::Alternative, :alternative)
17
22
  self.phase = PHASE_ANY
18
23
  collect
19
24
  end
20
25
 
26
+ # @return [Boolean]
21
27
  def error?
22
28
  error.present?
23
29
  end
24
30
 
31
+ # @return [Boolean]
25
32
  def success?
26
33
  !error?
27
34
  end
28
35
 
36
+ # @return [EacRubyUtils::Struct]
29
37
  def parsed
30
38
  @parsed ||= collector.to_data.freeze
31
39
  end
32
40
 
33
41
  private
34
42
 
43
+ # @return [Symbol]
35
44
  attr_accessor :phase
36
45
 
46
+ # @return [void]
37
47
  def any_collect_argv_value
38
48
  %w[double_dash long_option short_option].each do |arg_type|
39
49
  return send("#{arg_type}_collect_argv_value") if send("argv_current_#{arg_type}?")
@@ -42,10 +52,12 @@ module EacCli
42
52
  positional_collect_argv_value
43
53
  end
44
54
 
55
+ # @return [EacCli::Parser::Collector]
45
56
  def collector
46
57
  @collector ||= ::EacCli::Parser::Collector.new(alternative)
47
58
  end
48
59
 
60
+ # @return [void]
49
61
  def collect
50
62
  loop do
51
63
  break unless argv_pending?
@@ -57,21 +69,29 @@ module EacCli
57
69
  @error = e
58
70
  end
59
71
 
72
+ # @return [void]
60
73
  def collect_argv_value
61
74
  send("#{phase}_collect_argv_value")
62
75
  argv_enum.next
63
76
  end
64
77
 
78
+ # @param message [String]
79
+ # @raise [EacCli::Parser::Error] Always.
65
80
  def raise_error(message)
66
81
  raise ::EacCli::Parser::Error.new(alternative, argv, message)
67
82
  end
68
83
 
84
+ # @return [void]
85
+ # @raise [EacCli::Parser::Error] If options where not properly supplied.
69
86
  def validate
70
87
  (alternative.options + alternative.positional).each do |option|
71
88
  validate_option(option)
72
89
  end
73
90
  end
74
91
 
92
+ # @param option [EacCli::Definition::Option, EacCli::Definition::Positional]
93
+ # @return [void]
94
+ # @raise [EacCli::Parser::Error] If option was not properly supplied.
75
95
  def validate_option(option)
76
96
  return unless option.required?
77
97
  return if collector.supplied?(option)
@@ -14,29 +14,38 @@ module EacCli
14
14
  end
15
15
  end
16
16
 
17
+ # @!method initialize(definition)
18
+ # @param definition [EacCli::Definition]
17
19
  common_constructor :definition do
18
20
  default_values
19
21
  end
20
22
 
21
- # @return [OpenStruct]
23
+ # @return [EacRubyUtils::Struct]
22
24
  def to_data
23
25
  ::EacRubyUtils::Struct.new(data.transform_keys(&:identifier))
24
26
  end
25
27
 
28
+ # @param option [EacCli::Definition::Option]
29
+ # @param value [String]
30
+ # @return [void]
26
31
  def collect(option, value)
27
32
  data[option] = option.build_value(value, data[option])
28
33
  end
29
34
 
35
+ # @param option [EacCli::Definition::Option]
36
+ # @return [Boolean]
30
37
  def supplied?(option)
31
38
  data[option].present?
32
39
  end
33
40
 
34
41
  private
35
42
 
43
+ # @return [Hash]
36
44
  def data
37
45
  @data ||= {}
38
46
  end
39
47
 
48
+ # @return [void]
40
49
  def default_values
41
50
  definition.options.each { |option| data[option] = option.default_value }
42
51
  definition.positional.each { |positional| data[positional] = positional.default_value }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_exts'
3
+ require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module EacCli
6
6
  module Rspec
@@ -29,7 +29,7 @@ module EacCli
29
29
 
30
30
  def run_parser_error(runner_instance, error)
31
31
  $stderr.write("#{runner_instance.program_name}: #{error}\n")
32
- ::Kernel.exit(PARSER_ERROR_EXIT_CODE) # rubocop:disable Rails/Exit
32
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
33
33
  end
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.38.0'
4
+ VERSION = '0.38.1'
5
5
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/alternative'
4
+ require 'eac_cli/parser/alternative'
5
+
6
+ RSpec.describe EacCli::Parser::Alternative, '#subcommands' do
7
+ let(:instance) { described_class.new(alternative, argv) }
8
+ let(:actual_parsed) { instance.parsed.to_h.symbolize_keys }
9
+ let(:alternative) do
10
+ r = EacCli::Definition::Alternative.new
11
+ r.bool_opt '-b', '--opt1', 'A boolean option'
12
+ r.arg_opt '-a', '--opt2', 'A argument option'
13
+ r.subcommands
14
+ r
15
+ end
16
+
17
+ context 'with all values' do
18
+ let(:argv) { %w[--opt1 --opt2 OPT2 CMD CMD_ARG_1 --CMD_ARG_2] }
19
+ let(:parsed_expected) do
20
+ {
21
+ opt1: true, opt2: 'OPT2',
22
+ EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
23
+ EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => %w[CMD_ARG_1 --CMD_ARG_2]
24
+ }
25
+ end
26
+
27
+ it { expect(instance.error).to be_blank }
28
+ it { expect(actual_parsed).to eq(parsed_expected) }
29
+ end
30
+
31
+ context 'with only required values' do
32
+ let(:argv) { %w[CMD] }
33
+ let(:parsed_expected) do
34
+ {
35
+ opt1: false, opt2: nil,
36
+ EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
37
+ EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
38
+ }
39
+ end
40
+
41
+ it { expect(instance.error).to be_blank }
42
+ it { expect(actual_parsed).to eq(parsed_expected) }
43
+ end
44
+
45
+ context 'without required values' do
46
+ let(:argv) { %w[--opt1] }
47
+ let(:parsed_expected) do
48
+ {
49
+ opt1: true, opt2: nil,
50
+ EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => nil,
51
+ EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
52
+ }
53
+ end
54
+
55
+ it { expect(instance.error).to be_present }
56
+ it { expect(actual_parsed).to eq(parsed_expected) }
57
+ end
58
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/definition/alternative'
3
4
  require 'eac_cli/parser/alternative'
4
5
 
5
6
  RSpec.describe EacCli::Parser::Alternative do
@@ -85,56 +86,4 @@ RSpec.describe EacCli::Parser::Alternative do
85
86
  it { expect(actual_parsed).to eq(parsed_expected) }
86
87
  end
87
88
  end
88
-
89
- context 'with subcommands' do
90
- let(:alternative) do
91
- r = EacCli::Definition::Alternative.new
92
- r.bool_opt '-b', '--opt1', 'A boolean option'
93
- r.arg_opt '-a', '--opt2', 'A argument option'
94
- r.subcommands
95
- r
96
- end
97
-
98
- context 'with all values' do
99
- let(:argv) { %w[--opt1 --opt2 OPT2 CMD CMD_ARG_1 --CMD_ARG_2] }
100
- let(:parsed_expected) do
101
- {
102
- opt1: true, opt2: 'OPT2',
103
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
104
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => %w[CMD_ARG_1 --CMD_ARG_2]
105
- }
106
- end
107
-
108
- it { expect(instance.error).to be_blank }
109
- it { expect(actual_parsed).to eq(parsed_expected) }
110
- end
111
-
112
- context 'with only required values' do
113
- let(:argv) { %w[CMD] }
114
- let(:parsed_expected) do
115
- {
116
- opt1: false, opt2: nil,
117
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
118
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
119
- }
120
- end
121
-
122
- it { expect(instance.error).to be_blank }
123
- it { expect(actual_parsed).to eq(parsed_expected) }
124
- end
125
-
126
- context 'without required values' do
127
- let(:argv) { %w[--opt1] }
128
- let(:parsed_expected) do
129
- {
130
- opt1: true, opt2: nil,
131
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => nil,
132
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
133
- }
134
- end
135
-
136
- it { expect(instance.error).to be_present }
137
- it { expect(actual_parsed).to eq(parsed_expected) }
138
- end
139
- end
140
89
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
 
5
- RSpec.describe EacCli::Runner, '#for_context' do # rubocop:disable RSpec/MultipleMemoizedHelpers
5
+ RSpec.describe EacCli::Runner, '#for_context' do
6
6
  let(:parent_runner_class) do
7
7
  example = self
8
8
  Class.new do
@@ -61,7 +61,7 @@ RSpec.describe EacCli::Runner, '#for_context' do # rubocop:disable RSpec/Multipl
61
61
  it { expect(parent_runner.for_context?(:method_for_context)).to be(true) }
62
62
  it { expect(parent_runner.for_context?(:method_not_for_context)).to be(false) }
63
63
 
64
- context 'when method is for context' do # rubocop:disable RSpec/MultipleMemoizedHelpers
64
+ context 'when method is for context' do
65
65
  let(:child_runner_class) { child_runner_class1 }
66
66
 
67
67
  it do
@@ -69,7 +69,7 @@ RSpec.describe EacCli::Runner, '#for_context' do # rubocop:disable RSpec/Multipl
69
69
  end
70
70
  end
71
71
 
72
- context 'when method is not for context' do # rubocop:disable RSpec/MultipleMemoizedHelpers
72
+ context 'when method is not for context' do
73
73
  let(:child_runner_class) { child_runner_class2 }
74
74
 
75
75
  it do
@@ -56,7 +56,7 @@ RSpec.describe EacCli::RunnerWith::Output do
56
56
  end
57
57
  end
58
58
 
59
- context 'without --output option as to default file' do # rubocop:disable RSpec/MultipleMemoizedHelpers
59
+ context 'without --output option as to default file' do
60
60
  let(:output_file) { temp_dir.join('default_file') }
61
61
  let(:runner_argv) do
62
62
  ['--output', EacCli::RunnerWith::Output::DEFAULT_FILE_OPTION,
@@ -69,7 +69,7 @@ RSpec.describe EacCli::RunnerWith::Output do
69
69
  it { expect(output_file.read).to eq(stub_text) }
70
70
  end
71
71
 
72
- context 'with --output option' do # rubocop:disable RSpec/MultipleMemoizedHelpers
72
+ context 'with --output option' do
73
73
  let(:output_file) { temp_dir.join('a output file') }
74
74
  let(:runner_argv) { ['--output', output_file.to_path, stub_text] }
75
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.81.0
4
+ version: 0.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-04 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.82'
19
+ version: '0.83'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.82'
26
+ version: '0.83'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-eac_asciidoctor_base0
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -282,14 +282,14 @@ dependencies:
282
282
  requirements:
283
283
  - - "~>"
284
284
  - !ruby/object:Gem::Version
285
- version: '0.158'
285
+ version: '0.159'
286
286
  type: :runtime
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
- version: '0.158'
292
+ version: '0.159'
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: eac_ruby_utils
295
295
  requirement: !ruby/object:Gem::Requirement
@@ -1094,6 +1094,8 @@ files:
1094
1094
  - sub/avm-tools/lib/avm/tools/runner/source/issue.rb
1095
1095
  - sub/avm-tools/lib/avm/tools/runner/source/issue/complete.rb
1096
1096
  - sub/avm-tools/lib/avm/tools/runner/source/issue/deliver.rb
1097
+ - sub/avm-tools/lib/avm/tools/runner/source/sub.rb
1098
+ - sub/avm-tools/lib/avm/tools/runner/source/sub/remove.rb
1097
1099
  - sub/avm-tools/lib/avm/tools/runner/source/subs.rb
1098
1100
  - sub/avm-tools/lib/avm/tools/runner/source/test.rb
1099
1101
  - sub/avm-tools/lib/avm/tools/runner/source/update.rb
@@ -1318,6 +1320,8 @@ files:
1318
1320
  - sub/avm/lib/avm/sources/base/organizational.rb
1319
1321
  - sub/avm/lib/avm/sources/base/parent.rb
1320
1322
  - sub/avm/lib/avm/sources/base/stereotype.rb
1323
+ - sub/avm/lib/avm/sources/base/sub.rb
1324
+ - sub/avm/lib/avm/sources/base/sub/remove.rb
1321
1325
  - sub/avm/lib/avm/sources/base/subs.rb
1322
1326
  - sub/avm/lib/avm/sources/base/subs_paths.rb
1323
1327
  - sub/avm/lib/avm/sources/base/testing.rb
@@ -1339,6 +1343,8 @@ files:
1339
1343
  - sub/avm/lib/avm/version_number.rb
1340
1344
  - sub/avm/lib/avm/with/application_stereotype.rb
1341
1345
  - sub/avm/lib/avm/with/extra_subcommands.rb
1346
+ - sub/avm/locale/en.yml
1347
+ - sub/avm/locale/pt-BR.yml
1342
1348
  - sub/avm/spec/lib/avm/applications/base/entries_spec.rb
1343
1349
  - sub/avm/spec/lib/avm/applications/base/entries_spec_files/config.yml
1344
1350
  - sub/avm/spec/lib/avm/applications/base_spec.rb
@@ -1373,12 +1379,12 @@ files:
1373
1379
  - sub/eac_cli/lib/eac_cli/definition.rb
1374
1380
  - sub/eac_cli/lib/eac_cli/definition/alternative.rb
1375
1381
  - sub/eac_cli/lib/eac_cli/definition/argument_option.rb
1376
- - sub/eac_cli/lib/eac_cli/definition/base_option.rb
1377
- - sub/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb
1378
1382
  - sub/eac_cli/lib/eac_cli/definition/boolean_option.rb
1379
- - sub/eac_cli/lib/eac_cli/definition/default_value.rb
1380
1383
  - sub/eac_cli/lib/eac_cli/definition/error.rb
1381
- - sub/eac_cli/lib/eac_cli/definition/positional_argument.rb
1384
+ - sub/eac_cli/lib/eac_cli/definition/option.rb
1385
+ - sub/eac_cli/lib/eac_cli/definition/option/initialize_args_parser.rb
1386
+ - sub/eac_cli/lib/eac_cli/definition/option_or_positional.rb
1387
+ - sub/eac_cli/lib/eac_cli/definition/positional.rb
1382
1388
  - sub/eac_cli/lib/eac_cli/enum.rb
1383
1389
  - sub/eac_cli/lib/eac_cli/old_configs.rb
1384
1390
  - sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb
@@ -1443,6 +1449,7 @@ files:
1443
1449
  - sub/eac_cli/lib/eac_cli/version.rb
1444
1450
  - sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb
1445
1451
  - sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb
1452
+ - sub/eac_cli/spec/lib/eac_cli/parser/alternative/subcommands_spec.rb
1446
1453
  - sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb
1447
1454
  - sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb
1448
1455
  - sub/eac_cli/spec/lib/eac_cli/runner_spec.rb
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition/default_value'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module EacCli
7
- class Definition
8
- class BaseOption
9
- require_sub __FILE__
10
- include ::EacCli::Definition::DefaultValue
11
-
12
- class << self
13
- def from_args(args)
14
- p = ::EacCli::Definition::BaseOption::InitializeArgsParser.new(args)
15
- new(p.short, p.long, p.description, p.options)
16
- end
17
- end
18
-
19
- DEFAULT_REQUIRED = false
20
-
21
- enable_listable
22
- enable_abstract_methods :build_value
23
- lists.add_symbol :option, :default, :optional, :usage, :repeat, :required
24
- common_constructor :short, :long, :description, :options, default: [{}] do
25
- raise 'Nor short neither long selector was set' if short.blank? && long.blank?
26
-
27
- self.options = ::EacCli::Definition::BaseOption.lists.option.hash_keys_validate!(
28
- options.symbolize_keys
29
- )
30
- end
31
-
32
- def default_value
33
- default_value? ? options[OPTION_DEFAULT] : default_default_value
34
- end
35
-
36
- def default_value?
37
- options.key?(OPTION_DEFAULT)
38
- end
39
-
40
- def identifier
41
- [long, short].each do |v|
42
- v.to_s.if_present { |vv| return vv.variableize.to_sym }
43
- end
44
-
45
- raise(::EacCli::Definition::Error, 'No short or long option to build identifier')
46
- end
47
-
48
- def repeat?
49
- options[OPTION_REPEAT]
50
- end
51
-
52
- def required?
53
- return true if options.key?(:required) && options.fetch(:required)
54
- return false if options.key?(:optional) && options.fetch(:optional)
55
-
56
- DEFAULT_REQUIRED
57
- end
58
-
59
- def to_s
60
- "#{self.class.name.demodulize}[#{identifier}]"
61
- end
62
-
63
- def show_on_usage?
64
- options[:usage]
65
- end
66
- end
67
- end
68
- end
@@ -1,17 +0,0 @@
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