ehbrs-tools 0.16.4 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +31 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/music.rb +9 -0
- data/lib/ehbrs/music/album.rb +42 -0
- data/lib/ehbrs/observers/base.rb +1 -1
- data/lib/ehbrs/observers/with_persistence.rb +1 -1
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
- data/lib/ehbrs/runner/music.rb +16 -0
- data/lib/ehbrs/runner/music/selected.rb +63 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/runner/videos/unsupported.rb +1 -1
- data/lib/ehbrs/runner/web_utils/videos/upload.rb +1 -1
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/track.rb +1 -19
- data/lib/ehbrs/videos/unsupported/check_support.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
- data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +4 -7
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +21 -9
- data/vendor/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb +47 -0
- data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +12 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +15 -1
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +3 -17
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -48
- data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +31 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +15 -3
- data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +4 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +43 -4
- data/vendor/eac_ruby_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmable.rb +21 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +48 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
- metadata +87 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -35,19 +35,6 @@ module Ehbrs
|
|
35
35
|
video.tracks.flat_map(&:ffmpeg_fix_args)
|
36
36
|
end
|
37
37
|
|
38
|
-
def track_fix_args(track)
|
39
|
-
["#{track_codec_option_by_type(track.type)}:#{track.number}",
|
40
|
-
track.passed? ? 'copy' : track_codec_fix_by_type(track.type)]
|
41
|
-
end
|
42
|
-
|
43
|
-
def track_codec_option_by_type(track_type)
|
44
|
-
TRACK_TYPE_OPTIONS.fetch(track_type)
|
45
|
-
end
|
46
|
-
|
47
|
-
def track_codec_fix_by_type(track_type)
|
48
|
-
TRACK_TYPE_FIX_CODECS.fetch(track_type)
|
49
|
-
end
|
50
|
-
|
51
38
|
def container_fix_args
|
52
39
|
['-f', ::Ehbrs::Videos::Unsupported::Fixes::SupportedContainer::FIX_FORMAT]
|
53
40
|
end
|
@@ -6,28 +6,28 @@ module Ehbrs
|
|
6
6
|
module Fixes
|
7
7
|
class SupportedCodec
|
8
8
|
TRACK_TYPE_OPTIONS = {
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
audio: '-acodec',
|
10
|
+
video: '-vcodec',
|
11
|
+
subtitle: '-scodec'
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
TRACK_TYPE_FIX_CODECS = {
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
audio: 'aac',
|
16
|
+
video: 'libx264',
|
17
|
+
subtitle: 'ass'
|
18
18
|
}.freeze
|
19
19
|
|
20
20
|
def ffmpeg_args(track)
|
21
|
-
["#{track_codec_option_by_type(track.
|
22
|
-
track_codec_fix_by_type(track.
|
21
|
+
["#{track_codec_option_by_type(track.codec_type)}:#{track.index}",
|
22
|
+
track_codec_fix_by_type(track.codec_type)]
|
23
23
|
end
|
24
24
|
|
25
25
|
def track_codec_option_by_type(track_type)
|
26
|
-
TRACK_TYPE_OPTIONS.fetch(track_type)
|
26
|
+
TRACK_TYPE_OPTIONS.fetch(track_type.to_s.underscore.to_sym)
|
27
27
|
end
|
28
28
|
|
29
29
|
def track_codec_fix_by_type(track_type)
|
30
|
-
TRACK_TYPE_FIX_CODECS.fetch(track_type)
|
30
|
+
TRACK_TYPE_FIX_CODECS.fetch(track_type.to_s.underscore.to_sym)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ehbrs/videos/unsupported/profiles/base'
|
4
|
+
|
5
|
+
module Ehbrs
|
6
|
+
module Videos
|
7
|
+
module Unsupported
|
8
|
+
module Profiles
|
9
|
+
class Aoc < ::Ehbrs::Videos::Unsupported::Profiles::Base
|
10
|
+
AUDIO_SUPPORTED_CODECS = %w[aac ac3 mp2 mp3].freeze
|
11
|
+
AUDIO_UNSUPPORTED_CODECS = %w[eac3 vorbis].freeze
|
12
|
+
|
13
|
+
VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4].freeze
|
14
|
+
VIDEO_UNSUPPORTED_CODECS = %w[hevc].freeze
|
15
|
+
|
16
|
+
SUBTITLE_SUPPORTED_CODECS = %w[ass dvd_subtitle hdmv_pgs_subtitle subrip].freeze
|
17
|
+
SUBTITLE_UNSUPPORTED_CODECS = %w[mov_text].freeze
|
18
|
+
|
19
|
+
OTHER_SUPPORTED_CODECS = %w[].freeze
|
20
|
+
|
21
|
+
MPEG4_EXTRA_SUPPORTED = %w[xvid].freeze
|
22
|
+
MPEG4_EXTRA_UNSUPPORTED = %w[].freeze
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= title %></title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
|
8
|
+
rel="stylesheet"
|
9
|
+
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
|
10
|
+
crossorigin="anonymous">
|
11
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
|
12
|
+
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
|
13
|
+
crossorigin="anonymous"
|
14
|
+
></script>
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<h1><%= title %></h1>
|
18
|
+
<%= inner_content %>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h2><%= title %></h2>
|
2
|
+
<h3>Ingredientes</h3>
|
3
|
+
<% if notes.present? %>
|
4
|
+
<%= notes %>
|
5
|
+
<% end %>
|
6
|
+
<table class="table">
|
7
|
+
<thead>
|
8
|
+
<tr>
|
9
|
+
<th scope="col">Ingrediente</th>
|
10
|
+
<th scope="col">Medida</th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% ingredients.each do |ingredient| %>
|
15
|
+
<tr>
|
16
|
+
<th scope="row"><%= ingredient.name %></th>
|
17
|
+
<td><%= ingredient.measure %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
<h3>Preparo</h3>
|
23
|
+
<ol>
|
24
|
+
<% steps.each do |step| %>
|
25
|
+
<li><%= step %></li>
|
26
|
+
<% end %>
|
27
|
+
</ol>
|
@@ -10,15 +10,12 @@ module EacCli
|
|
10
10
|
SUBCOMMAND_NAME_ARG = :subcommand
|
11
11
|
SUBCOMMAND_ARGS_ARG = :subcommand_args
|
12
12
|
|
13
|
-
def arg_opt(
|
14
|
-
options_set << ::EacCli::Definition::ArgumentOption.
|
15
|
-
short, long, description, option_options
|
16
|
-
)
|
13
|
+
def arg_opt(*args)
|
14
|
+
options_set << ::EacCli::Definition::ArgumentOption.from_args(args)
|
17
15
|
end
|
18
16
|
|
19
|
-
def bool_opt(
|
20
|
-
options_set << ::EacCli::Definition::BooleanOption.
|
21
|
-
option_options)
|
17
|
+
def bool_opt(*args)
|
18
|
+
options_set << ::EacCli::Definition::BooleanOption.from_args(args)
|
22
19
|
end
|
23
20
|
|
24
21
|
def options
|
@@ -5,24 +5,36 @@ require 'eac_ruby_utils/core_ext'
|
|
5
5
|
module EacCli
|
6
6
|
class Definition
|
7
7
|
class BaseOption
|
8
|
+
require_sub __FILE__
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def from_args(args)
|
12
|
+
p = ::EacCli::Definition::BaseOption::InitializeArgsParser.new(args)
|
13
|
+
new(p.short, p.long, p.description, p.options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
DEFAULT_REQUIRED = false
|
9
18
|
|
10
19
|
enable_listable
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@options.assert_valid_keys(::EacCli::Definition::BaseOption.lists.option.values)
|
20
|
+
enable_abstract_methods :build_value, :default_value
|
21
|
+
lists.add_symbol :option, :optional, :usage, :repeat, :required
|
22
|
+
common_constructor :short, :long, :description, :options, default: [{}] do
|
23
|
+
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
24
|
+
|
25
|
+
self.options = ::EacCli::Definition::BaseOption.lists.option.hash_keys_validate!(
|
26
|
+
options.symbolize_keys
|
27
|
+
)
|
20
28
|
end
|
21
29
|
|
22
30
|
def identifier
|
23
31
|
long.to_s.variableize.to_sym
|
24
32
|
end
|
25
33
|
|
34
|
+
def repeat?
|
35
|
+
options[OPTION_REPEAT]
|
36
|
+
end
|
37
|
+
|
26
38
|
def required?
|
27
39
|
return true if options.key?(:required) && options.fetch(:required)
|
28
40
|
return false if options.key?(:optional) && options.fetch(:optional)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class Definition
|
5
|
+
class BaseOption
|
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}?") } || raise("Unknown type for \"#{value}\"")
|
30
|
+
end
|
31
|
+
|
32
|
+
def short?
|
33
|
+
value.start_with?('-') && !long?
|
34
|
+
end
|
35
|
+
|
36
|
+
def long?
|
37
|
+
value.start_with?('--')
|
38
|
+
end
|
39
|
+
|
40
|
+
def description?
|
41
|
+
!short? || !long?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -13,6 +13,18 @@ module EacCli
|
|
13
13
|
options.assert_valid_keys(self.class.lists.option.values)
|
14
14
|
end
|
15
15
|
|
16
|
+
def build_value(new_value, previous_value)
|
17
|
+
if previous_value.is_a?(::Array)
|
18
|
+
previous_value + [new_value]
|
19
|
+
else
|
20
|
+
new_value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_value
|
25
|
+
repeat? ? [] : nil
|
26
|
+
end
|
27
|
+
|
16
28
|
def identifier
|
17
29
|
name.to_s.variableize.to_sym
|
18
30
|
end
|
@@ -19,10 +19,24 @@ module EacCli
|
|
19
19
|
b += '=<value>' if option.argument?
|
20
20
|
b
|
21
21
|
end
|
22
|
+
|
23
|
+
def option_short(option)
|
24
|
+
b = option.short
|
25
|
+
b += '=<value>' if option.argument?
|
26
|
+
b
|
27
|
+
end
|
28
|
+
|
29
|
+
def option_usage_full(option)
|
30
|
+
if option.long.present?
|
31
|
+
[option.short, option_long(option)].reject(&:blank?).join(SEP)
|
32
|
+
else
|
33
|
+
option_short(option)
|
34
|
+
end
|
35
|
+
end
|
22
36
|
end
|
23
37
|
|
24
38
|
def option_definition(option)
|
25
|
-
|
39
|
+
self.class.option_usage_full(option) + OPTION_DESC_SEP + option.description
|
26
40
|
end
|
27
41
|
|
28
42
|
def section(header, include_header = true)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_cli/docopt/doc_builder'
|
4
|
+
require 'eac_cli/docopt/runner_context_replacement'
|
4
5
|
require 'eac_cli/runner'
|
5
6
|
require 'eac_ruby_utils/console/docopt_runner'
|
6
7
|
|
@@ -32,6 +33,10 @@ module EacCli
|
|
32
33
|
def docopt_options
|
33
34
|
super.merge(options_first: self.class.runner_definition.options_first?)
|
34
35
|
end
|
36
|
+
|
37
|
+
def runner_context
|
38
|
+
@runner_context ||= ::EacCli::Docopt::RunnerContextReplacement.new(self)
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
42
|
def extra_available_subcommands
|
@@ -35,11 +35,11 @@ module EacCli
|
|
35
35
|
attr_accessor :phase
|
36
36
|
|
37
37
|
def any_collect_argv_value
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
positional_collect_argv_value
|
38
|
+
%w[double_dash long_option short_option].each do |arg_type|
|
39
|
+
return send("#{arg_type}_collect_argv_value") if send("argv_current_#{arg_type}?")
|
42
40
|
end
|
41
|
+
|
42
|
+
positional_collect_argv_value
|
43
43
|
end
|
44
44
|
|
45
45
|
def collector
|
@@ -0,0 +1,37 @@
|
|
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 || raise_argv_current_invalid_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
|