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,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module LongOptions
7
- LONG_OPTION_PREFIX = '--'
8
- OPTION_WITH_ARGUMENT_PATTERN = /\A([^=]+)(?:=(.*))\z/.freeze
9
-
10
- private
11
-
12
- def argv_current_long_option?
13
- phase == PHASE_ANY && argv_enum.peek.start_with?(LONG_OPTION_PREFIX) &&
14
- !argv_current_double_dash?
15
- end
16
-
17
- def long_option_collect_argv_value
18
- option_long, value = parse_option_current_argv
19
- alternative.options.any? do |option|
20
- next false unless option.long == option_long
21
-
22
- if value.nil?
23
- option_collect_option(option)
24
- else
25
- option_argument_collect(option, value)
26
- end
27
- end || any_option_collect_option
28
- end
29
-
30
- def parse_option_current_argv
31
- m = OPTION_WITH_ARGUMENT_PATTERN.match(argv_enum.peek)
32
- m ? [m[1], m[2].if_present('')] : [argv_enum.peek, nil]
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module OptionArgument
7
- private
8
-
9
- attr_accessor :argument_option
10
-
11
- def argument_option_collect_argv(option)
12
- self.argument_option = option
13
- self.phase = PHASE_OPTION_ARGUMENT
14
- end
15
-
16
- def option_argument_collect(option, value)
17
- collector.collect(option, value)
18
- self.argument_option = nil
19
- self.phase = PHASE_ANY
20
- option
21
- end
22
-
23
- def option_argument_collect_argv_value
24
- option_argument_collect(argument_option, argv_enum.peek)
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module Options
7
- private
8
-
9
- def boolean_option_collect_argv(option)
10
- collector.collect(option, true)
11
- end
12
-
13
- def option_collect_option(option)
14
- if option.argument?
15
- argument_option_collect_argv(option)
16
- else
17
- boolean_option_collect_argv(option)
18
- end
19
-
20
- option
21
- end
22
-
23
- def raise_argv_current_invalid_option
24
- raise_error "Invalid option: \"#{argv_enum.peek}\""
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module Positionals
7
- private
8
-
9
- def positional_collect_argv_value
10
- positional_check
11
- collector.collect(positional_enum.peek, argv_enum.peek)
12
- positional_next
13
- end
14
-
15
- def positional_enum
16
- @positional_enum ||= alternative.positional.each
17
- end
18
-
19
- def positional_check
20
- raise_error("Invalid positional: #{argv_enum.peek}") if positional_enum.stopped?
21
- end
22
-
23
- def positional_next
24
- self.phase = PHASE_POSITIONAL if positional_enum.peek.subcommand?
25
- positional_enum.next unless positional_enum.peek.repeat?
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacCli
4
- class Parser
5
- class Alternative
6
- module ShortOptions
7
- SHORT_OPTION_PREFIX = '-'
8
- SHORT_OPTION_CHAR_PATTERN = /\A[0-9a-zA-Z]\z/.freeze
9
-
10
- private
11
-
12
- # @return [Boolean]
13
- def argv_current_short_option?
14
- phase == PHASE_ANY && argv_enum.peek.start_with?(SHORT_OPTION_PREFIX) &&
15
- !argv_current_long_option?
16
- end
17
-
18
- # @para char [String]
19
- # @return [EacCli::Definition::Option, nil]
20
- def find_short_option(char)
21
- alternative.options.find do |option|
22
- short_without_prefix(option.short).if_present(false) { |v| v == char }
23
- end
24
- end
25
-
26
- # @return [void]
27
- def short_option_collect_argv_value
28
- last_option = nil
29
- short_without_prefix(argv_enum.peek).each_char do |char|
30
- raise_error "Invalid option: \"#{char}\"" unless SHORT_OPTION_CHAR_PATTERN.match?(char)
31
- raise_error "Option \"#{last_option}\" requires a argument not provided" if
32
- last_option.present?
33
-
34
- collected_option = short_option_collect_char(char)
35
- last_option = collected_option if collected_option.argument?
36
- end
37
- end
38
-
39
- # @param char [String]
40
- # @return [EacCli::Definition::Option] The option collected.
41
- def short_option_collect_char(char)
42
- option = find_short_option(char)
43
- option ? option_collect_option(option) : any_option_collect_option
44
- end
45
-
46
- # @param short [String]
47
- # @return [String]
48
- def short_without_prefix(short)
49
- short.to_s.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/parser/collector'
4
- require 'eac_cli/parser/error'
5
- require 'eac_ruby_utils/core_ext'
6
-
7
- module EacCli
8
- class Parser
9
- class Alternative
10
- require_sub __FILE__, include_modules: true
11
- enable_listable
12
- lists.add_symbol :phase, :any, :option_argument, :positional
13
-
14
- # @return [EacCli::Parser::Error, nil]
15
- attr_reader :error
16
-
17
- # @!method initialize(alternative, argv)
18
- # @param alternative [EacCli::Definition::Alternative]
19
- # @param argv [Array<String>]
20
- common_constructor :alternative, :argv do
21
- alternative.assert_argument(::EacCli::Definition::Alternative, :alternative)
22
- self.phase = PHASE_ANY
23
- collect
24
- end
25
-
26
- # @return [Boolean]
27
- def error?
28
- error.present?
29
- end
30
-
31
- # @return [Boolean]
32
- def success?
33
- !error?
34
- end
35
-
36
- # @return [EacRubyUtils::Struct]
37
- def parsed
38
- @parsed ||= collector.to_data.freeze
39
- end
40
-
41
- private
42
-
43
- # @return [Symbol]
44
- attr_accessor :phase
45
-
46
- # @return [void]
47
- def any_collect_argv_value
48
- %w[double_dash long_option short_option].each do |arg_type|
49
- return send("#{arg_type}_collect_argv_value") if send("argv_current_#{arg_type}?")
50
- end
51
-
52
- positional_collect_argv_value
53
- end
54
-
55
- # @return [EacCli::Parser::Collector]
56
- def collector
57
- @collector ||= ::EacCli::Parser::Collector.new(alternative)
58
- end
59
-
60
- # @return [void]
61
- def collect
62
- loop do
63
- break unless argv_pending?
64
-
65
- collect_argv_value
66
- end
67
- validate
68
- rescue ::EacCli::Parser::Error => e
69
- @error = e
70
- end
71
-
72
- # @return [void]
73
- def collect_argv_value
74
- send("#{phase}_collect_argv_value")
75
- argv_enum.next
76
- end
77
-
78
- # @param message [String]
79
- # @raise [EacCli::Parser::Error] Always.
80
- def raise_error(message)
81
- raise ::EacCli::Parser::Error.new(alternative, argv, message)
82
- end
83
-
84
- # @return [void]
85
- # @raise [EacCli::Parser::Error] If options where not properly supplied.
86
- def validate
87
- (alternative.options + alternative.positional).each do |option|
88
- validate_option(option)
89
- end
90
- end
91
-
92
- # @param option [EacCli::Definition::Option, EacCli::Definition::Positional]
93
- # @return [void]
94
- # @raise [EacCli::Parser::Error] If option was not properly supplied.
95
- def validate_option(option)
96
- return unless option.required?
97
- return if collector.supplied?(option)
98
-
99
- raise_error("Required option/positional #{option} not supplied")
100
- end
101
- end
102
- end
103
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/struct'
5
-
6
- module EacCli
7
- class Parser
8
- class Collector
9
- class << self
10
- def to_data(definition)
11
- collector = new(definition)
12
- yield(collector)
13
- collector.to_data
14
- end
15
- end
16
-
17
- # @!method initialize(definition)
18
- # @param definition [EacCli::Definition]
19
- common_constructor :definition do
20
- default_values
21
- end
22
-
23
- # @return [EacRubyUtils::Struct]
24
- def to_data
25
- ::EacRubyUtils::Struct.new(data.transform_keys(&:identifier))
26
- end
27
-
28
- # @param option [EacCli::Definition::Option]
29
- # @param value [String]
30
- # @return [void]
31
- def collect(option, value)
32
- data[option] = option.build_value(value, data[option])
33
- end
34
-
35
- # @param option [EacCli::Definition::Option]
36
- # @return [Boolean]
37
- def supplied?(option)
38
- data[option].present?
39
- end
40
-
41
- private
42
-
43
- # @return [Hash]
44
- def data
45
- @data ||= {}
46
- end
47
-
48
- # @return [void]
49
- def default_values
50
- definition.options.each { |option| data[option] = option.default_value }
51
- definition.positional.each { |positional| data[positional] = positional.default_value }
52
- end
53
- end
54
- end
55
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- class Parser
7
- class Error < ::StandardError
8
- def initialize(definition, argv, message)
9
- @definition = definition
10
- @argv = argv
11
- super(message)
12
- end
13
- end
14
- end
15
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- class Parser
7
- require_sub __FILE__
8
- enable_simple_cache
9
- common_constructor :definition, :argv
10
-
11
- private
12
-
13
- def parsed_uncached
14
- raise 'Definition has no alternatives' if alternatives.empty?
15
- raise first_error unless alternatives.any?(&:success?)
16
-
17
- alternatives_parsed(true).merge(alternatives_parsed(false))
18
- end
19
-
20
- def alternatives_parsed(error)
21
- alternatives.select { |a| error == a.error? }.map(&:parsed).reverse
22
- .inject(::EacRubyUtils::Struct.new) { |a, e| a.merge(e) }
23
- end
24
-
25
- def alternatives_uncached
26
- definition.alternatives
27
- .map { |alternative| ::EacCli::Parser::Alternative.new(alternative, argv) }
28
- end
29
-
30
- def first_error_uncached
31
- alternatives.lazy.select(&:error?).map(&:error).first
32
- end
33
- end
34
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_cli/runner'
5
- require 'eac_cli/runner_with'
6
- require 'eac_cli/runner_with_set'
7
-
8
- class Object
9
- def runner_with(*runners, &block)
10
- include ::EacCli::Runner
11
- enable_simple_cache
12
- enable_speaker
13
- runners.each do |runner|
14
- include ::EacCli::RunnerWithSet.default.item_to_module(runner)
15
- end
16
- runner_definition(&block) if block
17
- end
18
-
19
- private
20
-
21
- def runner_with_to_module(runner)
22
- return runner if runner.is_a?(::Module)
23
-
24
- "EacCli::RunnerWith::#{runner.to_s.camelize}".constantize
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Dir["#{File.dirname(__FILE__)}/#{File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
- require path
5
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- EacRubyUtils.require_sub(__FILE__)
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/config/entry'
4
- require 'eac_cli/speaker'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'eac_ruby_utils/speaker'
7
-
8
- module EacCli
9
- module Rspec
10
- module Setup
11
- def disable_input_request
12
- disable_config_input_request
13
- disable_speaker_input_request
14
- end
15
-
16
- def disable_config_input_request
17
- rspec_config.before do
18
- allow_any_instance_of(::EacCli::Config::Entry).to receive(:input_value) do |obj|
19
- raise "Console input requested for entry (Path: #{obj.path})"
20
- end
21
- end
22
- end
23
-
24
- def disable_speaker_input_request
25
- ::RSpec.configure do |config|
26
- config.around do |example|
27
- ::EacRubyUtils::Speaker
28
- .context.on(::EacCli::Speaker.new(in_in: FailIfRequestInput.new)) { example.run }
29
- end
30
- end
31
- end
32
-
33
- class FailIfRequestInput
34
- %w[gets noecho].each do |method|
35
- define_method(method) do
36
- raise "Input method requested: #{method}. Should not request input on RSpec."
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- module Rspec
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition'
4
- require 'eac_cli/definition/error'
5
- require 'eac_cli/runner/class_runner'
6
-
7
- module EacCli
8
- module Runner
9
- module AfterClassMethods
10
- # @return [EacCli::Runner::ClassRunner]
11
- def class_runner(runner_context_args)
12
- ::EacCli::Runner::ClassRunner.new(self, runner_context_args)
13
- end
14
-
15
- def create(*runner_context_args)
16
- class_runner(runner_context_args).create
17
- end
18
-
19
- def run(*runner_context_args)
20
- class_runner(runner_context_args).run
21
- end
22
-
23
- def runner_definition(&block)
24
- @runner_definition ||= super_runner_definition
25
- begin
26
- @runner_definition.instance_eval(&block) if block
27
- rescue ::EacCli::Definition::Error => _e
28
- raise ::EacCli::Definition::Error, "Definition error for #{self}"
29
- end
30
- @runner_definition
31
- end
32
-
33
- def super_runner_definition
34
- superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
35
- end
36
- end
37
- end
38
- end
@@ -1,36 +0,0 @@
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
- r = create
22
- begin
23
- r.run_run
24
- rescue ::EacCli::Parser::Error => e
25
- run_parser_error(r, e)
26
- end
27
- r
28
- end
29
-
30
- def run_parser_error(runner_instance, error)
31
- $stderr.write("#{runner_instance.program_name}: #{error}\n")
32
- ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
33
- end
34
- end
35
- end
36
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_cli/runner/context_responders/parent'
5
- require 'eac_cli/runner/context_responders/runner'
6
- require 'eac_cli/runner/context_responders/runner_missing_method'
7
- require 'eac_cli/runner/context_responders/set'
8
-
9
- module EacCli
10
- module Runner
11
- class Context
12
- attr_reader :argv, :parent, :program_name, :runner
13
-
14
- def initialize(runner, *context_args)
15
- options = context_args.extract_options!
16
- @argv = (context_args[0] || options.delete(:argv) || ARGV).dup.freeze
17
- @parent = context_args[1] || options.delete(:parent)
18
- @program_name = options.delete(:program_name)
19
- @runner = runner
20
- end
21
-
22
- # Call a method in the runner or in one of it ancestors.
23
- def call(method_name, *args, &block)
24
- context_call_responder(method_name).call(*args, &block)
25
- end
26
-
27
- # @return [EacCli::Runner::ContextResponders]
28
- def context_call_responder(method_name)
29
- ::EacCli::Runner::ContextResponders::Set.new(self, method_name, %i[runner parent])
30
- end
31
-
32
- # @param method_name [Symbol]
33
- # @return [EacCli::Runner::ContextResponders::Parent]
34
- def runner_missing_method_responder(method_name)
35
- ::EacCli::Runner::ContextResponders::RunnerMissingMethod
36
- .new(self, method_name)
37
- end
38
-
39
- # @param method_name [Symbol]
40
- # @return [Boolean]
41
- def parent_respond_to?(method_name)
42
- parent.if_present(false) do |v|
43
- next true if v.respond_to?(method_name)
44
-
45
- v.if_respond(:runner_context, false) { |w| w.parent_respond_to?(method_name) }
46
- end
47
- end
48
-
49
- def parent_call(method_name, *args, &block)
50
- return parent.runner_context.call(method_name, *args, &block) if
51
- parent.respond_to?(:runner_context)
52
-
53
- raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
54
- end
55
-
56
- # @param method_name [Symbol]
57
- # @return [EacCli::Runner::ContextResponders::Parent]
58
- def parent_responder(method_name)
59
- ::EacCli::Runner::ContextResponders::Parent.new(self, method_name)
60
- end
61
- end
62
- end
63
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacCli
6
- module Runner
7
- module ContextResponders
8
- class Base
9
- acts_as_abstract :call, :callable?
10
- common_constructor :context, :method_name do
11
- self.method_name = method_name.to_sym
12
- end
13
- delegate :parent, :runner, to: :context
14
-
15
- def if_callable
16
- return false unless callable?
17
-
18
- yield(self)
19
- true
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_cli/runner/context_responders/base'
5
-
6
- module EacCli
7
- module Runner
8
- module ContextResponders
9
- class Parent < ::EacCli::Runner::ContextResponders::Base
10
- def callable?
11
- parent.if_present(false) do |v|
12
- next true if v.respond_to?(method_name)
13
-
14
- v.if_respond(:runner_context, false) { |w| w.parent_respond_to?(method_name) }
15
- end
16
- end
17
-
18
- def call(*args, &block)
19
- return parent.runner_context.call(method_name, *args, &block) if
20
- parent.respond_to?(:runner_context)
21
-
22
- raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
23
- end
24
- end
25
- end
26
- end
27
- end