avm-tools 0.68.0 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/instance/files_unit.rb +1 -1
  3. data/lib/avm/eac_rails_base0/apache_host.rb +17 -0
  4. data/lib/avm/eac_rails_base0/apache_path.rb +50 -0
  5. data/lib/avm/eac_rails_base0/deploy.rb +51 -0
  6. data/lib/avm/eac_rails_base0/instance.rb +14 -0
  7. data/lib/avm/eac_redmine_base0/deploy.rb +4 -4
  8. data/lib/avm/eac_redmine_base0/instance.rb +6 -5
  9. data/lib/avm/eac_ubuntu_base0/apache.rb +26 -0
  10. data/lib/avm/eac_ubuntu_base0/apache/resource.rb +59 -0
  11. data/lib/avm/eac_ubuntu_base0/docker_image.rb +14 -0
  12. data/lib/avm/eac_webapp_base0/apache_host.rb +103 -0
  13. data/lib/avm/eac_webapp_base0/deploy.rb +102 -0
  14. data/lib/avm/eac_webapp_base0/deploy/appended_directories.rb +25 -0
  15. data/lib/avm/eac_webapp_base0/deploy/file_unit.rb +42 -0
  16. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +49 -0
  17. data/lib/avm/eac_webapp_base0/deploy/version.rb +20 -0
  18. data/lib/avm/eac_webapp_base0/instance.rb +50 -0
  19. data/lib/avm/eac_webapp_base0/runner/apache_host.rb +39 -0
  20. data/lib/avm/eac_webapp_base0/runner/data.rb +25 -0
  21. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +69 -0
  22. data/lib/avm/eac_webapp_base0/runner/data/load.rb +66 -0
  23. data/lib/avm/eac_webapp_base0/runner/deploy.rb +59 -0
  24. data/lib/avm/git/issue/complete/_git_subrepos.rb +1 -0
  25. data/lib/avm/instances/base/auto_values/filesystem.rb +3 -1
  26. data/lib/avm/instances/entries.rb +5 -8
  27. data/lib/avm/instances/entry.rb +47 -0
  28. data/lib/avm/instances/entry_keys.rb +2 -0
  29. data/lib/avm/self/instance.rb +1 -1
  30. data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +3 -3
  31. data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +2 -2
  32. data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +2 -2
  33. data/lib/avm/tools/runner/eac_rails_base0.rb +9 -14
  34. data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +3 -26
  35. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +38 -0
  36. data/lib/avm/tools/runner/eac_rails_base0/data.rb +2 -2
  37. data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +3 -3
  38. data/lib/avm/tools/runner/eac_redmine_base0/data.rb +1 -1
  39. data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +2 -2
  40. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +2 -2
  41. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +1 -0
  42. data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +3 -25
  43. data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +2 -2
  44. data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +2 -2
  45. data/lib/avm/tools/runner/git/deploy.rb +3 -1
  46. data/lib/avm/tools/version.rb +1 -1
  47. data/template/avm/eac_rails_base0/apache_path/default.conf +13 -0
  48. data/template/avm/{stereotypes/eac_rails_base0 → eac_rails_base0}/deploy/config/database.yml.template +0 -0
  49. data/template/avm/{stereotypes/eac_webapp_base0 → eac_webapp_base0}/apache_host/no_ssl.conf +0 -0
  50. data/template/avm/self/docker_image/Dockerfile +1 -1
  51. data/vendor/eac_cli/Gemfile +5 -0
  52. data/vendor/eac_cli/eac_cli.gemspec +18 -0
  53. data/vendor/eac_cli/lib/eac_cli.rb +7 -0
  54. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
  55. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +14 -0
  56. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  57. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  58. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -0
  59. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  60. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +27 -0
  61. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +77 -0
  62. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
  63. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  64. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  65. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  66. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  67. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  68. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  69. data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
  70. data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
  71. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
  72. data/vendor/eac_cli/lib/eac_cli/runner.rb +87 -0
  73. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  74. data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
  75. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
  76. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
  77. data/vendor/eac_cli/lib/eac_cli/version.rb +5 -0
  78. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  79. data/vendor/eac_cli/spec/rubocop_spec.rb +7 -0
  80. data/vendor/eac_cli/spec/spec_helper.rb +100 -0
  81. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  82. data/vendor/eac_git/vendor/git-subrepo/lib/git-subrepo +9 -7
  83. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
  84. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +5 -1
  85. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  86. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +10 -0
  87. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +6 -5
  88. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +5 -34
  89. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +42 -0
  90. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
  91. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  92. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
  93. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  99. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  100. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  102. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
  103. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
  104. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  105. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  106. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  107. metadata +66 -22
  108. data/lib/avm/instances/entries/entry_reader.rb +0 -45
  109. data/lib/avm/stereotypes/eac_rails_base0/apache_host.rb +0 -19
  110. data/lib/avm/stereotypes/eac_rails_base0/deploy.rb +0 -52
  111. data/lib/avm/stereotypes/eac_rails_base0/instance.rb +0 -16
  112. data/lib/avm/stereotypes/eac_ubuntu_base0/apache.rb +0 -27
  113. data/lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb +0 -61
  114. data/lib/avm/stereotypes/eac_ubuntu_base0/docker_image.rb +0 -16
  115. data/lib/avm/stereotypes/eac_webapp_base0/apache_host.rb +0 -97
  116. data/lib/avm/stereotypes/eac_webapp_base0/deploy.rb +0 -104
  117. data/lib/avm/stereotypes/eac_webapp_base0/deploy/appended_directories.rb +0 -27
  118. data/lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb +0 -43
  119. data/lib/avm/stereotypes/eac_webapp_base0/deploy/git_info.rb +0 -51
  120. data/lib/avm/stereotypes/eac_webapp_base0/deploy/version.rb +0 -22
  121. data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +0 -52
  122. data/lib/avm/stereotypes/eac_webapp_base0/runner/data.rb +0 -27
  123. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/dump.rb +0 -71
  124. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb +0 -68
  125. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +0 -61
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'optparse'
5
+
6
+ module EacCli
7
+ class Parser
8
+ class OptionsCollection
9
+ SEP = ' '
10
+ IDENT = SEP * 2
11
+ OPTION_DESC_SEP = IDENT * 2
12
+
13
+ enable_simple_cache
14
+ common_constructor(:definition, :argv, :collector) { collect }
15
+ attr_reader :arguments
16
+
17
+ private
18
+
19
+ def collect
20
+ build_banner
21
+ build_options
22
+ @arguments = option_parser.parse(argv)
23
+ end
24
+
25
+ def option_parser_uncached
26
+ ::OptionParser.new
27
+ end
28
+
29
+ def build_banner
30
+ option_parser.banner = "#{definition.description}\n\n#{section('usage')}"
31
+ end
32
+
33
+ def build_options
34
+ definition.options.each do |option|
35
+ build_option(option)
36
+ end
37
+ end
38
+
39
+ def build_option(option)
40
+ option_parser.on(
41
+ *[option_short(option), option_long(option), option.description].reject(&:blank?)
42
+ ) do |value|
43
+ collector.collect(option, value)
44
+ end
45
+ end
46
+
47
+ def positional_argument(positional)
48
+ if positional.subcommand?
49
+ ::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
50
+ else
51
+ r = "<#{positional.name}>"
52
+ r += '...' if positional.repeat?
53
+ r = "[#{r}]" if positional.optional?
54
+ r
55
+ end
56
+ end
57
+
58
+ def option_argument(option)
59
+ option_long(option)
60
+ end
61
+
62
+ def option_long(option)
63
+ b = option.long
64
+ b += '=VALUE' if option.argument?
65
+ b
66
+ end
67
+
68
+ def option_short(option)
69
+ b = option.short
70
+ b += 'VALUE' if option.argument?
71
+ b
72
+ end
73
+
74
+ def section(header, include_header = true)
75
+ b = include_header ? "#{header.humanize}:\n" : ''
76
+ b += send("self_#{header}") + "\n"
77
+ # TO-DO: implement alternatives
78
+ b
79
+ end
80
+
81
+ def self_options
82
+ definition.options.map { |option| IDENT + option_definition(option) }.join("\n")
83
+ end
84
+
85
+ def self_usage
86
+ IDENT + self_usage_arguments.join(SEP)
87
+ end
88
+
89
+ def self_usage_arguments
90
+ [::EacRubyUtils::Console::DocoptRunner::PROGRAM_MACRO] +
91
+ definition.options_argument.if_present([]) { |_v| ['[options]'] } +
92
+ self_usage_arguments_options +
93
+ self_usage_arguments_positional
94
+ end
95
+
96
+ def self_usage_arguments_options
97
+ definition.options.select(&:show_on_usage?).map { |option| option_argument(option) }
98
+ end
99
+
100
+ def self_usage_arguments_positional
101
+ definition.positional.map { |p| positional_argument(p) }
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Parser
7
+ class ParseResult
8
+ common_constructor :definition, :argv
9
+
10
+ def result
11
+ ::EacCli::Parser::Collector.to_data(definition) do |collector|
12
+ ::EacCli::Parser::PositionalCollection.new(
13
+ definition,
14
+ ::EacCli::Parser::OptionsCollection.new(definition, argv, collector).arguments,
15
+ collector
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/parser/error'
5
+
6
+ module EacCli
7
+ class Parser
8
+ class PositionalCollection
9
+ common_constructor(:definition, :argv, :collector) { collect }
10
+
11
+ private
12
+
13
+ def collected
14
+ @collected ||= ::Set.new
15
+ end
16
+
17
+ def collect
18
+ argv.each { |argv_value| colect_argv_value(argv_value) }
19
+ return unless pending_required_positional?
20
+
21
+ raise ::EacCli::Parser::Error.new(
22
+ definition, argv, 'No value for required positional ' \
23
+ "\"#{current_positional.identifier}\""
24
+ )
25
+ end
26
+
27
+ def colect_argv_value(argv_value)
28
+ collector.collect(current_positional, argv_value)
29
+ collected << current_positional
30
+ positional_enumerator.next unless current_positional.repeat?
31
+ end
32
+
33
+ def pending_required_positional?
34
+ !(current_positional.blank? || current_positional.optional? ||
35
+ collected.include?(current_positional))
36
+ end
37
+
38
+ def positional_enumerator
39
+ @positional_enumerator ||= definition.positional.each
40
+ end
41
+
42
+ def current_positional
43
+ positional_enumerator.peek
44
+ rescue ::StopIteration
45
+ nil
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
+ require path
5
+ end
@@ -0,0 +1,24 @@
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
+
7
+ class Object
8
+ def runner_with(*runners)
9
+ include ::EacCli::Runner
10
+ enable_simple_cache
11
+ enable_console_speaker
12
+ runners.each do |runner|
13
+ include runner_with_to_module(runner)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def runner_with_to_module(runner)
20
+ return runner if runner.is_a?(::Module)
21
+
22
+ "EacCli::RunnerWith::#{runner.to_s.camelize}".constantize
23
+ end
24
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition'
4
+ require 'eac_cli/docopt/runner_extension'
5
+ require 'eac_cli/parser'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module EacCli
9
+ module Runner
10
+ require_sub __FILE__
11
+ extend ::ActiveSupport::Concern
12
+
13
+ class << self
14
+ def alias_runner_class_methods(klass, from_suffix, to_suffix)
15
+ %i[create run].each do |method|
16
+ alias_class_method(klass, build_method_name(method, from_suffix),
17
+ build_method_name(method, to_suffix))
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def alias_class_method(klass, from, to)
24
+ sklass = klass.singleton_class
25
+ return unless sklass.method_defined?(from)
26
+
27
+ sklass.alias_method to, from
28
+ end
29
+
30
+ def build_method_name(name, suffix)
31
+ ss = suffix.if_present('') { |s| "#{s}_" }
32
+ "#{ss}#{name}"
33
+ end
34
+ end
35
+
36
+ the_module = self
37
+ included do
38
+ the_module.alias_runner_class_methods(self, '', 'original')
39
+
40
+ extend AfterClassMethods
41
+ include InstanceMethods
42
+ ::EacCli::Docopt::RunnerExtension.check(self)
43
+ end
44
+
45
+ module AfterClassMethods
46
+ def create(*runner_context_args)
47
+ r = new
48
+ r.runner_context = ::EacCli::Runner::Context.new(*runner_context_args)
49
+ r
50
+ end
51
+
52
+ def run(*runner_context_args)
53
+ r = create(*runner_context_args)
54
+ r.parsed
55
+ r.run
56
+ r
57
+ end
58
+
59
+ def runner_definition(&block)
60
+ @runner_definition ||= super_runner_definition
61
+ @runner_definition.instance_eval(&block) if block
62
+ @runner_definition
63
+ end
64
+
65
+ def super_runner_definition
66
+ superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
67
+ end
68
+ end
69
+
70
+ module InstanceMethods
71
+ def runner_context
72
+ return @runner_context if @runner_context
73
+
74
+ raise 'Context was required, but was not set yet'
75
+ end
76
+
77
+ def runner_context=(new_runner_context)
78
+ @runner_context = new_runner_context
79
+ @parsed = nil
80
+ end
81
+
82
+ def parsed
83
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition).parse(runner_context.argv)
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module Runner
7
+ class Context
8
+ attr_reader :argv, :parent, :program_name
9
+
10
+ def initialize(*context_args)
11
+ options = context_args.extract_options!
12
+ @argv = (context_args[0] || options.delete(:argv) || ARGV).dup.freeze
13
+ @parent = context_args[1] || options.delete(:parent)
14
+ @program_name = options.delete(:program_name)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module RunnerWith
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module Help
9
+ common_concern do
10
+ include ::EacCli::Runner
11
+
12
+ runner_definition.alt do
13
+ options_arg false
14
+ bool_opt '-h', '--help', 'Show help.', usage: true
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module OutputFile
9
+ common_concern do
10
+ include ::EacCli::Runner
11
+
12
+ runner_definition do
13
+ arg_opt '-o', '--output-file', 'Output to file.'
14
+ end
15
+ end
16
+
17
+ def run_output
18
+ if parsed.output_file.present?
19
+ ::File.write(parsed.output_file, output_content)
20
+ else
21
+ out output_content
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ VERSION = '0.8.0'
5
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_cli/runner'
5
+
6
+ RSpec.describe ::EacCli::Runner do
7
+ let(:stub_runner) do
8
+ r = Class.new(::EacRubyUtils::Console::DocoptRunner) do
9
+ def run; end
10
+ end
11
+ r.include described_class
12
+ r.runner_definition do
13
+ desc 'A stub runner.'
14
+ arg_opt '-o', '--opt1', 'A argument option'
15
+ pos_arg 'pos1'
16
+ end
17
+ r
18
+ end
19
+
20
+ let(:instance) { stub_runner.new(argv: %w[-o aaa bbb]) }
21
+
22
+ before { instance.run }
23
+
24
+ it { expect(instance.options.fetch('--opt1')).to eq('aaa') }
25
+ it { expect(instance.options.fetch('<pos1>')).to eq('bbb') }
26
+
27
+ context 'without docopt runner' do
28
+ let(:runner_class) do
29
+ the_module = described_class
30
+ ::Class.new do
31
+ include the_module
32
+
33
+ runner_definition do
34
+ arg_opt '-o', '--opt1', 'A arg option.'
35
+ bool_opt '-o', '--opt2', 'A boolean option'
36
+ pos_arg :pos1
37
+ pos_arg :pos2, repeat: true, optional: true
38
+ end
39
+
40
+ def run; end
41
+ end
42
+ end
43
+
44
+ context 'when all args are supplied' do
45
+ let(:instance) { runner_class.create(%w[--opt1 aaa --opt2 bbb ccc ddd]) }
46
+
47
+ it { expect(instance.parsed.opt1).to eq('aaa') }
48
+ it { expect(instance.parsed.opt2?).to eq(true) }
49
+ it { expect(instance.parsed.pos1).to eq('bbb') }
50
+ it { expect(instance.parsed.pos2).to eq(%w[ccc ddd]) }
51
+ end
52
+
53
+ context 'when only required args are supplied' do
54
+ let(:instance) { runner_class.create(%w[bbb]) }
55
+
56
+ it { expect(instance.parsed.opt1).to be_nil }
57
+ it { expect(instance.parsed.opt2?).to eq(false) }
58
+ it { expect(instance.parsed.pos1).to eq('bbb') }
59
+ it { expect(instance.parsed.pos2).to eq([]) }
60
+ end
61
+
62
+ context 'when required args are not supplied' do
63
+ let(:instance) { runner_class.create(%w[]) }
64
+
65
+ it do
66
+ expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
67
+ end
68
+ end
69
+ end
70
+ end