eac_tools 0.82.0 → 0.83.0

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.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +45 -40
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +4 -3
  5. data/sub/avm/lib/avm/data/rotate.rb +1 -1
  6. data/sub/avm/lib/avm/launcher/instances/base/publishing.rb +1 -1
  7. data/sub/avm/lib/avm/registry/from_gems.rb +2 -2
  8. data/sub/avm/lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb +0 -1
  9. data/sub/avm/lib/avm/source_generators/base.rb +1 -0
  10. data/sub/avm/lib/avm/source_generators/runner.rb +6 -0
  11. data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
  12. data/sub/avm/lib/avm/version.rb +1 -1
  13. data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/avm-tools_stub/avm-tools.gemspec +1 -0
  14. data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/ruby_gem_stub/ruby_gem_stub.gemspec +1 -0
  15. data/sub/avm-eac_asciidoctor_base0/Gemfile +2 -2
  16. data/sub/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +6 -5
  17. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb +5 -3
  18. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +2 -2
  19. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/document.rb +2 -2
  20. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +1 -3
  21. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  22. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/file_formats/base_spec.rb +1 -1
  23. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec.rb +18 -18
  24. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec_files/pre_processed_root_body.adoc +1 -0
  25. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build_spec.rb +3 -3
  26. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec.rb +1 -1
  27. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb +2 -2
  28. data/sub/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +1 -1
  29. data/sub/avm-eac_asciidoctor_base0/spec/spec_helper/eac_asciidoctor_base0_stubs.rb +1 -1
  30. data/sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb +3 -3
  31. data/sub/avm-eac_python_base0/Gemfile +2 -2
  32. data/sub/avm-eac_python_base0/avm-eac_python_base0.gemspec +5 -4
  33. data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/executables.rb +1 -1
  34. data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/version.rb +1 -1
  35. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec.rb +1 -1
  36. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.source +1 -1
  37. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.target +1 -1
  38. data/sub/avm-eac_python_base0/spec/rubocop_spec.rb +1 -1
  39. data/sub/avm-eac_python_base0/spec/spec_helper.rb +1 -1
  40. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
  41. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb +2 -1
  42. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  43. metadata +14 -144
  44. data/sub/eac_cli/Gemfile +0 -8
  45. data/sub/eac_cli/eac_cli.gemspec +0 -22
  46. data/sub/eac_cli/lib/eac_cli/config/entry/options.rb +0 -58
  47. data/sub/eac_cli/lib/eac_cli/config/entry/undefined.rb +0 -31
  48. data/sub/eac_cli/lib/eac_cli/config/entry.rb +0 -60
  49. data/sub/eac_cli/lib/eac_cli/config.rb +0 -17
  50. data/sub/eac_cli/lib/eac_cli/core_ext.rb +0 -6
  51. data/sub/eac_cli/lib/eac_cli/default_runner.rb +0 -14
  52. data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +0 -105
  53. data/sub/eac_cli/lib/eac_cli/definition/argument_option.rb +0 -21
  54. data/sub/eac_cli/lib/eac_cli/definition/boolean_option.rb +0 -27
  55. data/sub/eac_cli/lib/eac_cli/definition/error.rb +0 -8
  56. data/sub/eac_cli/lib/eac_cli/definition/option/initialize_args_parser.rb +0 -48
  57. data/sub/eac_cli/lib/eac_cli/definition/option.rb +0 -73
  58. data/sub/eac_cli/lib/eac_cli/definition/option_or_positional.rb +0 -43
  59. data/sub/eac_cli/lib/eac_cli/definition/positional.rb +0 -53
  60. data/sub/eac_cli/lib/eac_cli/definition.rb +0 -109
  61. data/sub/eac_cli/lib/eac_cli/enum.rb +0 -45
  62. data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +0 -80
  63. data/sub/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb +0 -16
  64. data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +0 -44
  65. data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +0 -25
  66. data/sub/eac_cli/lib/eac_cli/old_configs.rb +0 -35
  67. data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +0 -19
  68. data/sub/eac_cli/lib/eac_cli/parser/alternative/argv.rb +0 -19
  69. data/sub/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +0 -24
  70. data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +0 -37
  71. data/sub/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +0 -29
  72. data/sub/eac_cli/lib/eac_cli/parser/alternative/options.rb +0 -29
  73. data/sub/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +0 -30
  74. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +0 -54
  75. data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -103
  76. data/sub/eac_cli/lib/eac_cli/parser/collector.rb +0 -55
  77. data/sub/eac_cli/lib/eac_cli/parser/error.rb +0 -15
  78. data/sub/eac_cli/lib/eac_cli/parser.rb +0 -34
  79. data/sub/eac_cli/lib/eac_cli/patches/object/runner_with.rb +0 -26
  80. data/sub/eac_cli/lib/eac_cli/patches/object.rb +0 -5
  81. data/sub/eac_cli/lib/eac_cli/patches.rb +0 -4
  82. data/sub/eac_cli/lib/eac_cli/rspec/setup.rb +0 -42
  83. data/sub/eac_cli/lib/eac_cli/rspec.rb +0 -9
  84. data/sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb +0 -38
  85. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +0 -36
  86. data/sub/eac_cli/lib/eac_cli/runner/context.rb +0 -63
  87. data/sub/eac_cli/lib/eac_cli/runner/context_responders/base.rb +0 -24
  88. data/sub/eac_cli/lib/eac_cli/runner/context_responders/parent.rb +0 -27
  89. data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner.rb +0 -20
  90. data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner_missing_method.rb +0 -32
  91. data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +0 -44
  92. data/sub/eac_cli/lib/eac_cli/runner/context_responders.rb +0 -11
  93. data/sub/eac_cli/lib/eac_cli/runner/exit.rb +0 -14
  94. data/sub/eac_cli/lib/eac_cli/runner/for_context.rb +0 -40
  95. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +0 -45
  96. data/sub/eac_cli/lib/eac_cli/runner.rb +0 -50
  97. data/sub/eac_cli/lib/eac_cli/runner_with/confirmation.rb +0 -44
  98. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +0 -63
  99. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +0 -81
  100. data/sub/eac_cli/lib/eac_cli/runner_with/help/layout.rb +0 -40
  101. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +0 -53
  102. data/sub/eac_cli/lib/eac_cli/runner_with/input.rb +0 -36
  103. data/sub/eac_cli/lib/eac_cli/runner_with/output.rb +0 -58
  104. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/base_formatter.rb +0 -15
  105. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/csv_formatter.rb +0 -23
  106. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/yaml_formatter.rb +0 -18
  107. data/sub/eac_cli/lib/eac_cli/runner_with/output_item.rb +0 -42
  108. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/base_formatter.rb +0 -30
  109. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/csv_formatter.rb +0 -26
  110. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/yaml_formatter.rb +0 -23
  111. data/sub/eac_cli/lib/eac_cli/runner_with/output_list.rb +0 -42
  112. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands/definition_concern.rb +0 -10
  113. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +0 -129
  114. data/sub/eac_cli/lib/eac_cli/runner_with.rb +0 -9
  115. data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +0 -56
  116. data/sub/eac_cli/lib/eac_cli/speaker/constants.rb +0 -13
  117. data/sub/eac_cli/lib/eac_cli/speaker/input_blocked.rb +0 -16
  118. data/sub/eac_cli/lib/eac_cli/speaker/input_requested.rb +0 -8
  119. data/sub/eac_cli/lib/eac_cli/speaker/list.rb +0 -61
  120. data/sub/eac_cli/lib/eac_cli/speaker/options.rb +0 -38
  121. data/sub/eac_cli/lib/eac_cli/speaker.rb +0 -127
  122. data/sub/eac_cli/lib/eac_cli/version.rb +0 -5
  123. data/sub/eac_cli/lib/eac_cli.rb +0 -7
  124. data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +0 -18
  125. data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +0 -14
  126. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative/subcommands_spec.rb +0 -58
  127. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +0 -89
  128. data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +0 -79
  129. data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +0 -129
  130. data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +0 -42
  131. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +0 -21
  132. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +0 -51
  133. data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +0 -81
  134. data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -98
  135. data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +0 -32
  136. data/sub/eac_cli/spec/rubocop_spec.rb +0 -3
  137. data/sub/eac_cli/spec/spec_helper.rb +0 -4
  138. data/sub/eac_config/Gemfile +0 -8
  139. data/sub/eac_config/eac_config.gemspec +0 -19
  140. data/sub/eac_config/lib/eac_config/entries.rb +0 -35
  141. data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +0 -13
  142. data/sub/eac_config/lib/eac_config/entry.rb +0 -64
  143. data/sub/eac_config/lib/eac_config/entry_path.rb +0 -89
  144. data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +0 -54
  145. data/sub/eac_config/lib/eac_config/envvars_node.rb +0 -35
  146. data/sub/eac_config/lib/eac_config/load_nodes_search.rb +0 -39
  147. data/sub/eac_config/lib/eac_config/load_path.rb +0 -28
  148. data/sub/eac_config/lib/eac_config/node.rb +0 -81
  149. data/sub/eac_config/lib/eac_config/node_entry.rb +0 -28
  150. data/sub/eac_config/lib/eac_config/node_uri/instanciate_single.rb +0 -29
  151. data/sub/eac_config/lib/eac_config/node_uri.rb +0 -45
  152. data/sub/eac_config/lib/eac_config/old_configs/base.rb +0 -43
  153. data/sub/eac_config/lib/eac_config/old_configs/file.rb +0 -47
  154. data/sub/eac_config/lib/eac_config/old_configs.rb +0 -75
  155. data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +0 -8
  156. data/sub/eac_config/lib/eac_config/paths_hash/node.rb +0 -67
  157. data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +0 -39
  158. data/sub/eac_config/lib/eac_config/paths_hash.rb +0 -63
  159. data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +0 -25
  160. data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +0 -19
  161. data/sub/eac_config/lib/eac_config/rspec/setup.rb +0 -65
  162. data/sub/eac_config/lib/eac_config/rspec.rb +0 -9
  163. data/sub/eac_config/lib/eac_config/version.rb +0 -5
  164. data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +0 -36
  165. data/sub/eac_config/lib/eac_config/yaml_file_node/self_entries.rb +0 -72
  166. data/sub/eac_config/lib/eac_config/yaml_file_node.rb +0 -54
  167. data/sub/eac_config/lib/eac_config.rb +0 -7
  168. data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +0 -30
  169. data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -14
  170. data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +0 -51
  171. data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +0 -46
  172. data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +0 -88
  173. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +0 -88
  174. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -10
  175. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -4
  176. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -4
  177. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -10
  178. data/sub/eac_config/spec/rubocop_spec.rb +0 -3
  179. data/sub/eac_config/spec/spec_helper.rb +0 -4
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition/option'
4
-
5
- module EacCli
6
- class Definition
7
- class BooleanOption < ::EacCli::Definition::Option
8
- def argument?
9
- false
10
- end
11
-
12
- def build_value(_new_value, previous_value)
13
- repeat? ? previous_value + 1 : true
14
- end
15
-
16
- def default_value
17
- return super unless default_value?
18
-
19
- raise("Unallowed default value for boolean options (Option: #{self})")
20
- end
21
-
22
- def default_default_value
23
- repeat? ? 0 : false
24
- end
25
- end
26
- end
27
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Definition
5
- class Error < ::StandardError
6
- end
7
- end
8
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Definition
5
- class Option
6
- class InitializeArgsParser
7
- PROPERTIES = %i[short long description options].freeze
8
- attr_reader(*PROPERTIES)
9
-
10
- def initialize(args)
11
- self.options = args.extract_options!.freeze
12
- args.each { |arg| absorb_arg(arg) }
13
- end
14
-
15
- private
16
-
17
- attr_writer(*PROPERTIES)
18
-
19
- def absorb_arg(arg)
20
- arg_ext = ArgumentParser.new(arg)
21
- send("#{arg_ext.type}=", arg_ext.value)
22
- end
23
-
24
- class ArgumentParser
25
- TYPES = %i[short long description].freeze
26
- common_constructor :value
27
-
28
- def type
29
- TYPES.find { |type| send("#{type}?") } ||
30
- raise(::EacCli::Definition::Error, "Unknown type for \"#{value}\"")
31
- end
32
-
33
- def short?
34
- value.start_with?('-') && !long?
35
- end
36
-
37
- def long?
38
- value.start_with?('--')
39
- end
40
-
41
- def description?
42
- !short? || !long?
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,73 +0,0 @@
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
@@ -1,43 +0,0 @@
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,53 +0,0 @@
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
- class Positional < ::EacCli::Definition::OptionOrPositional
9
- DEFAULT_REQUIRED = true
10
- DEFAULT_VISIBLE = true
11
-
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>]
17
- common_constructor :name, :options, default: [{}] do
18
- options.assert_valid_keys(self.class.lists.option.values)
19
- end
20
-
21
- # @param new_value [Array, Object]
22
- # @param previous_value [Array, Object]
23
- # @return [Array]
24
- def build_value(new_value, previous_value)
25
- if previous_value.is_a?(::Array)
26
- previous_value + [new_value]
27
- else
28
- new_value
29
- end
30
- end
31
-
32
- # @return [Object]
33
- def default_value
34
- repeat? ? [] : nil
35
- end
36
-
37
- # @return [Symbol]
38
- def identifier
39
- name.to_s.variableize.to_sym
40
- end
41
-
42
- # @return [Boolean]
43
- def subcommand?
44
- options[OPTION_SUBCOMMAND]
45
- end
46
-
47
- # @return [Boolean]
48
- def visible?
49
- options.key?(OPTION_VISIBLE) ? options.fetch(OPTION_VISIBLE) : DEFAULT_VISIBLE
50
- end
51
- end
52
- end
53
- end
@@ -1,109 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition/argument_option'
4
- require 'eac_cli/definition/boolean_option'
5
- require 'eac_cli/definition/positional'
6
- require 'eac_ruby_utils/core_ext'
7
-
8
- module EacCli
9
- class Definition
10
- require_sub __FILE__
11
-
12
- MAIN_ALTERNATIVE_KEY = :main
13
- SUBCOMMAND_NAME_ARG = 'subcommand'
14
- SUBCOMMAND_ARGS_ARG = 'subcommand_args'
15
-
16
- # @return [String, nil]
17
- attr_accessor :description
18
-
19
- def initialize
20
- self.description = '-- NO DESCRIPTION SET --'
21
- alternatives_set[MAIN_ALTERNATIVE_KEY] = main_alternative
22
- end
23
-
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
-
30
- r = ::EacCli::Definition::Alternative.new
31
- r.instance_eval(&block)
32
- alternatives_set[key] = r
33
- r
34
- end
35
-
36
- # @return [Enumerable<EacCli::Definition::Alternative>]
37
- def alternatives
38
- alternatives_set.values
39
- end
40
-
41
- # @return [EacCli::Definition::Alternative]
42
- # @raise [KeyError] If there is not a alternative with provided key.
43
- def alternative(key)
44
- alternatives_set.fetch(key)
45
- end
46
-
47
- # Same as {#description=}.
48
- def desc(description)
49
- self.description = description
50
- end
51
-
52
- # @return [EacCli::Definition::Alternative]
53
- def main_alternative
54
- @main_alternative ||= begin
55
- r = ::EacCli::Definition::Alternative.new
56
- r.options_argument(true)
57
- r
58
- end
59
- end
60
-
61
- # Same as {#options_argument=}.
62
- # @param options_argument [Boolean]
63
- def options_arg(options_argument)
64
- self.options_argument = options_argument
65
- end
66
-
67
- # @return [Boolean]
68
- def options_argument
69
- main_alternative.options_argument?
70
- end
71
-
72
- def options_argument=(enable)
73
- main_alternative.options_argument(enable)
74
- end
75
-
76
- delegate :arg_opt, :bool_opt, :options, :pos_arg,
77
- :positional, :subcommands, to: :main_alternative
78
-
79
- def subcommands?
80
- alternatives.any?(&:subcommands?)
81
- end
82
-
83
- def options_first(enable = true) # rubocop:disable Style/OptionalBooleanParameter
84
- @options_first = enable
85
- end
86
-
87
- def options_first?
88
- @options_first ? true : false
89
- end
90
-
91
- private
92
-
93
- def alternatives_set
94
- @alternatives_set ||= ::ActiveSupport::HashWithIndifferentAccess.new
95
- end
96
-
97
- def new_alternative_key
98
- @last_key ||= 0
99
- loop do
100
- @last_key += 1
101
- break @last_key unless alternatives_set.key?(@last_key)
102
- end
103
- end
104
-
105
- def pos_set
106
- @pos_set ||= []
107
- end
108
- end
109
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/enum'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module EacCli
7
- # A [EacRubyUtils::Enum] which each value is associated with one console color.
8
- class Enum < ::EacRubyUtils::Enum
9
- # Foreground color used in [to_bg_label]
10
- TO_BG_LABEL_FG_COLOR = :light_white
11
-
12
- attr_reader :color
13
-
14
- def initialize(key, color)
15
- super(key)
16
- @color = color
17
- end
18
-
19
- delegate :to_s, to: :key
20
-
21
- # @return [String]
22
- def to_label
23
- to_fg_label
24
- end
25
-
26
- # @return [String]
27
- def to_fg_label
28
- to_fg_bg_label(color)
29
- end
30
-
31
- # @return [String]
32
- def to_bg_label
33
- to_fg_bg_label(TO_BG_LABEL_FG_COLOR, color)
34
- end
35
-
36
- private
37
-
38
- # @return [String]
39
- def to_fg_bg_label(fg_color, bg_color = nil)
40
- colors = { color: fg_color }
41
- bg_color.if_present { |v| colors[:background] = v }
42
- ::ColorizedString[to_s].colorize(colors)
43
- end
44
- end
45
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/old_configs/read_entry_options'
4
- require 'eac_config/paths_hash'
5
- require 'eac_ruby_utils/core_ext'
6
-
7
- module EacCli
8
- class OldConfigs
9
- class EntryReader
10
- enable_speaker
11
-
12
- class << self
13
- def entry_key_to_envvar_name(entry_key)
14
- path = if entry_key.is_a?(::Array)
15
- entry_key
16
- else
17
- ::EacConfig::PathsHash.parse_entry_key(entry_key)
18
- end
19
- path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
20
- .gsub(/_{2,}/, '_').upcase
21
- end
22
- end
23
-
24
- common_constructor :console_configs, :entry_key, :options do
25
- self.options = ::EacCli::OldConfigs::ReadEntryOptions.new(options)
26
- end
27
-
28
- def read
29
- %w[envvars storage console].each do |suffix|
30
- value = send("read_from_#{suffix}")
31
- return value if value.present?
32
- end
33
- return nil unless options[:required]
34
-
35
- raise "No value found for entry \"#{entry_key}\""
36
- end
37
-
38
- def read_from_storage
39
- console_configs.configs.read_entry(entry_key)
40
- end
41
-
42
- def read_from_envvars
43
- return if options[:noenv]
44
-
45
- env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
46
- return unless ENV.key?(env_entry_key)
47
-
48
- ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
49
- end
50
-
51
- def read_from_console
52
- return if options[:noinput]
53
-
54
- options[:before_input].if_present(&:call)
55
- entry_value = looped_entry_value_from_input
56
- console_configs.configs.write_entry(entry_key, entry_value) if options[:store]
57
- entry_value
58
- end
59
-
60
- private
61
-
62
- def looped_entry_value_from_input
63
- loop do
64
- entry_value = entry_value_from_input(entry_key, options)
65
- next if entry_value.blank?
66
- next if options[:validator] && !options[:validator].call(entry_value)
67
-
68
- return entry_value
69
- end
70
- end
71
-
72
- def entry_value_from_input(entry_key, options)
73
- entry_value = input("Value for entry \"#{entry_key}\"",
74
- options.request_input_options)
75
- warn('Entered value is blank') if entry_value.blank?
76
- entry_value
77
- end
78
- end
79
- end
80
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/old_configs/entry_reader'
4
-
5
- module EacCli
6
- class OldConfigs
7
- class PasswordEntryReader < ::EacCli::OldConfigs::EntryReader
8
- ENTRY_KEY = 'core.store_passwords'
9
-
10
- def initialize(console_configs, entry_key, options = {})
11
- super(console_configs, entry_key, options.merge(noecho: true,
12
- store: console_configs.store_passwords?))
13
- end
14
- end
15
- end
16
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- class OldConfigs
7
- class ReadEntryOptions
8
- enable_simple_cache
9
- common_constructor :options do
10
- self.options = options.to_h.symbolize_keys
11
- .assert_valid_keys(DEFAULT_VALUES.keys).freeze
12
- end
13
-
14
- DEFAULT_VALUES = {
15
- before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
16
- required: true, store: true, validator: nil
17
- }.freeze
18
-
19
- delegate :to_h, to: :options
20
-
21
- def [](key)
22
- values.fetch(key.to_sym)
23
- end
24
-
25
- def request_input_options
26
- values.slice(:bool, :list, :noecho)
27
- end
28
-
29
- private
30
-
31
- def values_uncached
32
- consumer = options.to_options_consumer
33
- r = {}
34
- DEFAULT_VALUES.each do |key, default_value|
35
- value = consumer.consume(key)
36
- value = default_value if value.nil?
37
- r[key] = value
38
- end
39
- consumer.validate
40
- r
41
- end
42
- end
43
- end
44
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/old_configs/entry_reader'
4
-
5
- module EacCli
6
- class OldConfigs
7
- class StorePasswordsEntryReader < ::EacCli::OldConfigs::EntryReader
8
- ENTRY_KEY = 'core.store_passwords'
9
-
10
- def initialize(console_configs)
11
- super(console_configs, ENTRY_KEY,
12
- before_input: -> { banner },
13
- validator: ->(entry_value) { %w[yes no].include?(entry_value) }
14
- )
15
- end
16
-
17
- def banner
18
- infom 'Do you wanna to store passwords?'
19
- infom 'Warning: the passwords will be store in clear text in ' \
20
- "\"#{console_configs.configs.storage_path}\""
21
- infom 'Enter "yes" or "no"'
22
- end
23
- end
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- class OldConfigs
7
- require_sub __FILE__
8
- enable_speaker
9
-
10
- class << self
11
- def entry_key_to_envvar_name(entry_key)
12
- ::EacCli::OldConfigs::EntryReader.entry_key_to_envvar_name(entry_key)
13
- end
14
- end
15
-
16
- attr_reader :configs
17
-
18
- def initialize(configs_key, options = {})
19
- options.assert_argument(::Hash, 'options')
20
- @configs = ::EacConfig::OldConfigs.new(configs_key, options.merge(autosave: true))
21
- end
22
-
23
- def read_password(entry_key, options = {})
24
- ::EacCli::OldConfigs::PasswordEntryReader.new(self, entry_key, options).read
25
- end
26
-
27
- def read_entry(entry_key, options = {})
28
- ::EacCli::OldConfigs::EntryReader.new(self, entry_key, options).read
29
- end
30
-
31
- def store_passwords?
32
- ::EacCli::OldConfigs::StorePasswordsEntryReader.new(self) == 'yes'
33
- end
34
- end
35
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- class Parser
7
- class Alternative
8
- module AnyOptions
9
- delegate :any_option?, to: :alternative
10
-
11
- # @return [EacCli::Definition::BooleanOption] if #any_option? is true.
12
- # @raise [EacCli::Parser::Error] if #any_option? is false.
13
- def any_option_collect_option
14
- any_option? ? alternative.any_options_option : raise_argv_current_invalid_option
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module Argv
7
- # @return [Enumerator<String>]
8
- def argv_enum
9
- @argv_enum ||= argv.each
10
- end
11
-
12
- # @return [Boolean]
13
- def argv_pending?
14
- argv_enum.ongoing?
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module DoubleDash
7
- DOUBLE_DASH = '--'
8
-
9
- private
10
-
11
- attr_accessor :double_dash
12
-
13
- def argv_current_double_dash?
14
- argv_enum.peek == DOUBLE_DASH && !double_dash
15
- end
16
-
17
- def double_dash_collect_argv_value
18
- self.phase = PHASE_POSITIONAL
19
- self.double_dash = true
20
- end
21
- end
22
- end
23
- end
24
- end