ehbrs-tools 0.16.0 → 0.16.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/runner/videos/probe.rb +3 -3
  3. data/lib/ehbrs/tools/version.rb +1 -1
  4. data/lib/ehbrs/vg/wii/wit/parsers/dump.rb +10 -5
  5. data/lib/ehbrs/videos/file.rb +4 -8
  6. data/lib/ehbrs/videos/track.rb +5 -13
  7. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +3 -1
  8. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +3 -1
  9. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +4 -2
  10. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +3 -1
  11. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
  12. data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
  13. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
  14. data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
  15. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
  16. data/vendor/aranha-parsers/Gemfile +5 -0
  17. data/vendor/aranha-parsers/aranha-parsers.gemspec +23 -0
  18. data/vendor/aranha-parsers/lib/aranha/parsers.rb +9 -0
  19. data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +79 -0
  20. data/vendor/aranha-parsers/lib/aranha/parsers/html.rb +11 -0
  21. data/vendor/aranha-parsers/lib/aranha/parsers/html/base.rb +47 -0
  22. data/vendor/aranha-parsers/lib/aranha/parsers/html/item.rb +24 -0
  23. data/vendor/aranha-parsers/lib/aranha/parsers/html/item_list.rb +29 -0
  24. data/vendor/aranha-parsers/lib/aranha/parsers/html/node.rb +13 -0
  25. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/base.rb +36 -0
  26. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +126 -0
  27. data/vendor/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +8 -0
  28. data/vendor/aranha-parsers/lib/aranha/parsers/patches.rb +11 -0
  29. data/vendor/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
  30. data/vendor/aranha-parsers/lib/aranha/parsers/source_address.rb +55 -0
  31. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/file.rb +31 -0
  32. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +25 -0
  33. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +45 -0
  34. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +49 -0
  35. data/vendor/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +77 -0
  36. data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +78 -0
  37. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +7 -0
  38. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +21 -0
  39. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +74 -0
  40. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +27 -0
  41. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +1 -0
  42. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +1 -0
  43. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +1 -0
  44. data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +1 -0
  45. data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +7 -0
  46. data/vendor/aranha-parsers/spec/spec_helper.rb +8 -0
  47. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  48. data/vendor/eac_cli/lib/eac_cli/definition.rb +36 -31
  49. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  50. data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +76 -0
  51. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +15 -2
  52. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  53. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  54. data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
  55. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
  56. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  57. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  58. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  59. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  60. data/vendor/eac_cli/lib/eac_cli/runner.rb +12 -4
  61. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  62. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +18 -1
  63. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  64. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -1
  65. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  66. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  67. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  68. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  69. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +17 -5
  70. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  71. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  72. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -1
  73. data/vendor/eac_docker/lib/eac_docker/container.rb +24 -0
  74. data/vendor/eac_docker/lib/eac_docker/images/coded.rb +39 -0
  75. data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +26 -0
  76. data/vendor/eac_docker/lib/eac_docker/registry.rb +17 -0
  77. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  78. data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec.rb +12 -0
  79. data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +1 -0
  80. data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +17 -0
  81. data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +1 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
  99. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  100. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  102. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  103. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  104. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  105. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  106. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  107. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +30 -2
  108. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
  109. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
  110. metadata +92 -13
  111. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -127
  112. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  113. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
  114. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
  115. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module Argv
7
+ def argv_enum
8
+ @argv_enum ||= argv.each
9
+ end
10
+
11
+ def argv_pending?
12
+ argv_enum.ongoing?
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module Options
7
+ DOUBLE_DASH = '--'
8
+
9
+ private
10
+
11
+ attr_accessor :argument_option, :double_dash
12
+
13
+ def argument_option_collect_argv(option)
14
+ self.argument_option = option
15
+ self.phase = PHASE_OPTION_ARGUMENT
16
+ end
17
+
18
+ def argv_current_option?
19
+ phase == PHASE_ANY && argv_enum.peek.start_with?('-')
20
+ end
21
+
22
+ def argv_current_double_dash?
23
+ argv_enum.peek == DOUBLE_DASH && !double_dash
24
+ end
25
+
26
+ def boolean_option_collect_argv(option)
27
+ collector.collect(option, true)
28
+ end
29
+
30
+ def option_argument_collect_argv_value
31
+ collector.collect(argument_option, argv_enum.peek)
32
+ self.argument_option = nil
33
+ self.phase = PHASE_ANY
34
+ end
35
+
36
+ def option_collect_argv_value
37
+ return double_dash_collect_argv_value if argv_current_double_dash?
38
+
39
+ alternative.options.any? do |option|
40
+ next false unless [option.short, option.long].include?(argv_enum.peek)
41
+
42
+ if option.argument?
43
+ argument_option_collect_argv(option)
44
+ else
45
+ boolean_option_collect_argv(option)
46
+ end
47
+
48
+ true
49
+ end || raise_argv_current_invalid_option
50
+ end
51
+
52
+ def raise_argv_current_invalid_option
53
+ raise_error "Invalid option: \"#{argv_enum.peek}\""
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,30 @@
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
@@ -28,7 +28,7 @@ module EacCli
28
28
  sklass = klass.singleton_class
29
29
  return unless sklass.method_defined?(from)
30
30
 
31
- sklass.alias_method to, from
31
+ sklass.send(:alias_method, to, from)
32
32
  end
33
33
 
34
34
  def build_method_name(name, suffix)
@@ -44,6 +44,8 @@ module EacCli
44
44
  extend AfterClassMethods
45
45
  include InstanceMethods
46
46
  ::EacCli::Docopt::RunnerExtension.check(self)
47
+ include ActiveSupport::Callbacks
48
+ define_callbacks :run
47
49
  end
48
50
 
49
51
  module AfterClassMethods
@@ -55,8 +57,7 @@ module EacCli
55
57
 
56
58
  def run(*runner_context_args)
57
59
  r = create(*runner_context_args)
58
- r.parsed
59
- r.run
60
+ r.run_run
60
61
  r
61
62
  end
62
63
 
@@ -72,6 +73,13 @@ module EacCli
72
73
  end
73
74
 
74
75
  module InstanceMethods
76
+ def run_run
77
+ parsed
78
+ run_callbacks(:run) { run }
79
+ rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
80
+ # Do nothing
81
+ end
82
+
75
83
  def runner_context
76
84
  return @runner_context if @runner_context
77
85
 
@@ -84,7 +92,7 @@ module EacCli
84
92
  end
85
93
 
86
94
  def parsed
87
- @parsed ||= ::EacCli::Parser.new(self.class.runner_definition).parse(runner_context.argv)
95
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
88
96
  end
89
97
  end
90
98
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ class Exit < ::StandardError
6
+ attr_reader :status
7
+
8
+ def initialize(status = true)
9
+ @status = status
10
+ end
11
+ end
12
+ end
13
+ end
@@ -10,9 +10,26 @@ module EacCli
10
10
  include ::EacCli::Runner
11
11
 
12
12
  runner_definition.alt do
13
- options_arg false
13
+ options_argument false
14
14
  bool_opt '-h', '--help', 'Show help.', usage: true
15
15
  end
16
+
17
+ set_callback :run, :before do
18
+ help_run
19
+ end
20
+ end
21
+
22
+ def help_run
23
+ return unless parsed.help?
24
+
25
+ puts help_text
26
+ raise ::EacCli::Runner::Exit
27
+ end
28
+
29
+ def help_text
30
+ r = ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
31
+ r += help_extra_text if respond_to?(:help_extra_text)
32
+ r
16
33
  end
17
34
  end
18
35
  end
@@ -2,12 +2,16 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/abstract_methods'
5
6
 
6
7
  module EacCli
7
8
  module RunnerWith
8
9
  module OutputFile
9
10
  common_concern do
10
11
  include ::EacCli::Runner
12
+ include ::EacRubyUtils::AbstractMethods
13
+
14
+ abstract_methods :output_content
11
15
 
12
16
  runner_definition do
13
17
  arg_opt '-o', '--output-file', 'Output to file.'
@@ -18,7 +22,7 @@ module EacCli
18
22
  if parsed.output_file.present?
19
23
  ::File.write(parsed.output_file, output_content)
20
24
  else
21
- out output_content
25
+ $stdout.write(output_content)
22
26
  end
23
27
  end
24
28
  end
@@ -31,6 +31,11 @@ module EacCli
31
31
  end
32
32
  end
33
33
 
34
+ def help_extra_text
35
+ (['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
36
+ .map { |v| "#{v}\n" }.join
37
+ end
38
+
34
39
  def method_missing(method_name, *arguments, &block)
35
40
  return run_with_subcommand(*arguments, &block) if
36
41
  run_with_subcommand_alias_run?(method_name)
@@ -44,7 +49,7 @@ module EacCli
44
49
 
45
50
  def run_with_subcommand
46
51
  if subcommand_name
47
- subcommand_runner.run
52
+ subcommand_runner.run_run
48
53
  else
49
54
  run_without_subcommand
50
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.10.0'
4
+ VERSION = '0.12.4'
5
5
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/alternative'
4
+
5
+ RSpec.describe ::EacCli::Definition::Alternative do
6
+ let(:instance) { described_class.new }
7
+
8
+ it { expect { instance.arg_opt '-a', '--opt2', 'A argument option' }.not_to raise_error }
9
+ it { expect { instance.bool_opt '-b', '--opt1', 'A boolean option' }.not_to raise_error }
10
+ it { expect { instance.options_argument(true) }.not_to raise_error }
11
+ it { expect { instance.pos_arg :pos1 }.not_to raise_error }
12
+ it { expect { instance.pos_arg :pos2, optional: true, repeat: true }.not_to raise_error }
13
+ it { expect { instance.subcommands }.not_to raise_error }
14
+ end
@@ -22,4 +22,14 @@ RSpec.describe ::EacCli::Docopt::RunnerExtension do
22
22
 
23
23
  it { expect(instance.options.fetch('--opt1')).to eq('aaa') }
24
24
  it { expect(instance.options.fetch('<pos1>')).to eq('bbb') }
25
+ it { expect(instance.doc).to eq(<<~EXPECTED) }
26
+ A stub runner.
27
+
28
+ Usage:
29
+ __PROGRAM__ [options] <pos1>
30
+
31
+ Options:
32
+ -o --opt1=<value> A argument option
33
+
34
+ EXPECTED
25
35
  end
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/docopt/runner_extension'
4
+
5
+ RSpec.describe ::EacCli::Parser::Alternative do
6
+ let(:instance) { described_class.new(alternative, argv) }
7
+ let(:actual_parsed) { instance.parsed.to_h.symbolize_keys }
8
+
9
+ context 'without subcommands' do
10
+ let(:alternative) do
11
+ r = ::EacCli::Definition::Alternative.new
12
+ r.bool_opt '-b', '--opt1', 'A boolean option'
13
+ r.arg_opt '-a', '--opt2', 'A argument option'
14
+ r.bool_opt '-c', '--opt3', 'A required boolean option', required: true
15
+ r.pos_arg :pos1
16
+ r.pos_arg :pos2, optional: true, repeat: true
17
+ r
18
+ end
19
+
20
+ context 'with all values' do
21
+ let(:argv) { %w[--opt1 --opt2 OPT2 --opt3 POS1 POS2_1 POS2_2] }
22
+ let(:parsed_expected) do
23
+ {
24
+ opt1: true, opt2: 'OPT2', opt3: true, pos1: 'POS1', pos2: %w[POS2_1 POS2_2]
25
+ }
26
+ end
27
+
28
+ it { expect(instance.error).to be_blank }
29
+ it { expect(actual_parsed).to eq(parsed_expected) }
30
+ end
31
+
32
+ context 'with only required values' do
33
+ let(:argv) { %w[--opt3 POS1] }
34
+ let(:parsed_expected) { { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: [] } }
35
+
36
+ it { expect(instance.error).to be_blank }
37
+ it { expect(actual_parsed).to eq(parsed_expected) }
38
+ end
39
+
40
+ context 'with double dash' do
41
+ let(:argv) { %w[--opt3 POS1 -- --opt1 --] }
42
+ let(:parsed_expected) do
43
+ { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: %w[--opt1 --] }
44
+ end
45
+
46
+ it { expect(instance.error).to be_blank }
47
+ it { expect(actual_parsed).to eq(parsed_expected) }
48
+ end
49
+
50
+ context 'without required positional' do
51
+ let(:argv) { %w[--opt1 --opt3] }
52
+ let(:parsed_expected) { { opt1: true, opt2: nil, opt3: true, pos1: nil, pos2: [] } }
53
+
54
+ it { expect(instance.error).to be_present }
55
+ it { expect(actual_parsed).to eq(parsed_expected) }
56
+ end
57
+
58
+ context 'without required option' do
59
+ let(:argv) { %w[--opt1 POS1] }
60
+ let(:parsed_expected) { { opt1: true, opt2: nil, opt3: false, pos1: 'POS1', pos2: [] } }
61
+
62
+ it { expect(instance.error).to be_present }
63
+ it { expect(actual_parsed).to eq(parsed_expected) }
64
+ end
65
+
66
+ context 'without any required option or positional' do
67
+ let(:argv) { %w[] }
68
+ let(:parsed_expected) { { opt1: false, opt2: nil, opt3: false, pos1: nil, pos2: [] } }
69
+
70
+ it { expect(instance.error).to be_present }
71
+ it { expect(actual_parsed).to eq(parsed_expected) }
72
+ end
73
+
74
+ context 'with excedent positional' do
75
+ let(:alternative) do
76
+ r = ::EacCli::Definition::Alternative.new
77
+ r.pos_arg :pos1
78
+ r
79
+ end
80
+
81
+ let(:argv) { %w[POS1 POS2] }
82
+ let(:parsed_expected) { { pos1: 'POS1' } }
83
+
84
+ it { expect(instance.error).to be_present }
85
+ it { expect(actual_parsed).to eq(parsed_expected) }
86
+ end
87
+ 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
+ end