avm-tools 0.83.0 → 0.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_writings_base1/apache_host.rb +17 -0
  3. data/lib/avm/eac_writings_base1/build.rb +2 -2
  4. data/lib/avm/eac_writings_base1/deploy.rb +26 -0
  5. data/lib/avm/eac_writings_base1/instance.rb +11 -0
  6. data/lib/avm/git/file_auto_fixup.rb +22 -3
  7. data/lib/avm/instances/base/auto_values/database.rb +10 -0
  8. data/lib/avm/instances/entry_keys.rb +1 -1
  9. data/lib/avm/projects/stereotypes/git/update.rb +42 -0
  10. data/lib/avm/projects/stereotypes/git/update/subrepo.rb +85 -0
  11. data/lib/avm/tools/runner.rb +2 -4
  12. data/lib/avm/tools/runner/eac_rails_base0.rb +1 -1
  13. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +1 -1
  14. data/lib/avm/tools/runner/eac_redmine_base0.rb +1 -1
  15. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +1 -1
  16. data/lib/avm/tools/runner/eac_redmine_base0/docker.rb +1 -1
  17. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +1 -1
  18. data/lib/avm/tools/runner/eac_wordpress_base0.rb +1 -1
  19. data/lib/avm/tools/runner/eac_writings_base0.rb +1 -1
  20. data/lib/avm/tools/runner/eac_writings_base1.rb +15 -0
  21. data/lib/avm/tools/runner/files.rb +7 -15
  22. data/lib/avm/tools/runner/files/format.rb +18 -27
  23. data/lib/avm/tools/runner/files/rotate.rb +11 -21
  24. data/lib/avm/tools/runner/git.rb +10 -15
  25. data/lib/avm/tools/runner/git/auto_commit.rb +2 -2
  26. data/lib/avm/tools/runner/git/auto_fixup.rb +23 -16
  27. data/lib/avm/tools/runner/git/commit.rb +2 -2
  28. data/lib/avm/tools/runner/git/deploy.rb +18 -28
  29. data/lib/avm/tools/runner/git/dirty_files.rb +2 -2
  30. data/lib/avm/tools/runner/git/issue.rb +2 -2
  31. data/lib/avm/tools/runner/git/organize.rb +2 -2
  32. data/lib/avm/tools/runner/git/revisions_test.rb +2 -2
  33. data/lib/avm/tools/runner/git/subrepo.rb +2 -2
  34. data/lib/avm/tools/runner/git/subrepo/check.rb +2 -2
  35. data/lib/avm/tools/runner/git/subrepo/clone.rb +2 -2
  36. data/lib/avm/tools/runner/git/subrepo/fix.rb +4 -3
  37. data/lib/avm/tools/runner/instance.rb +1 -1
  38. data/lib/avm/tools/runner/instance/info.rb +1 -1
  39. data/lib/avm/tools/runner/launcher.rb +1 -1
  40. data/lib/avm/tools/runner/launcher/instances.rb +1 -1
  41. data/lib/avm/tools/runner/launcher/projects.rb +1 -1
  42. data/lib/avm/tools/runner/launcher/publish.rb +1 -1
  43. data/lib/avm/tools/runner/local_project.rb +5 -8
  44. data/lib/avm/tools/runner/local_project/eac_writings_base0.rb +5 -6
  45. data/lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb +4 -6
  46. data/lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb +4 -5
  47. data/lib/avm/tools/runner/local_project/eac_writings_base0/info.rb +4 -5
  48. data/lib/avm/tools/runner/local_project/eac_writings_base1.rb +2 -2
  49. data/lib/avm/tools/runner/local_project/eac_writings_base1/build.rb +2 -2
  50. data/lib/avm/tools/runner/local_project/info.rb +2 -2
  51. data/lib/avm/tools/runner/local_project/ruby.rb +2 -2
  52. data/lib/avm/tools/runner/local_project/ruby/bundler.rb +2 -2
  53. data/lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb +2 -2
  54. data/lib/avm/tools/runner/local_project/test.rb +2 -2
  55. data/lib/avm/tools/runner/local_project/update.rb +2 -2
  56. data/lib/avm/tools/runner/local_project/version_bump.rb +10 -13
  57. data/lib/avm/tools/runner/ruby.rb +1 -1
  58. data/lib/avm/tools/runner/ruby/gems.rb +1 -1
  59. data/lib/avm/tools/runner/ruby/gems/generate.rb +1 -1
  60. data/lib/avm/tools/runner/ruby/rubocop.rb +1 -1
  61. data/lib/avm/tools/runner/self.rb +1 -1
  62. data/lib/avm/tools/runner/self/docker.rb +1 -1
  63. data/lib/avm/tools/version.rb +1 -1
  64. data/template/avm/eac_rails_base0/deploy/config/database.yml.template +3 -2
  65. data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
  66. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
  67. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
  68. data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
  69. data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
  70. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
  71. data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
  72. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +14 -2
  73. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  74. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +22 -1
  75. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +1 -0
  76. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +9 -6
  77. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +4 -9
  78. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
  91. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
  92. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
  93. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
  94. metadata +16 -2
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
9
  class Launcher < ::EacRubyUtils::Console::DocoptRunner
10
10
  require_sub __FILE__
11
11
  include ::EacCli::DefaultRunner
@@ -4,7 +4,7 @@ require 'eac_launcher/instances/runner_helper'
4
4
 
5
5
  module Avm
6
6
  module Tools
7
- class Runner < ::EacRubyUtils::Console::DocoptRunner
7
+ class Runner
8
8
  class Launcher < ::EacRubyUtils::Console::DocoptRunner
9
9
  class Instances < ::EacLauncher::Instances::RunnerHelper
10
10
  DOC = <<~DOCOPT
@@ -5,7 +5,7 @@ require 'eac_launcher/instances/runner_helper'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
9
  class Launcher < ::EacRubyUtils::Console::DocoptRunner
10
10
  class Projects < ::EacLauncher::Instances::RunnerHelper
11
11
  DOC = <<~DOCOPT
@@ -4,7 +4,7 @@ require 'eac_launcher/instances/runner_helper'
4
4
 
5
5
  module Avm
6
6
  module Tools
7
- class Runner < ::EacRubyUtils::Console::DocoptRunner
7
+ class Runner
8
8
  class Launcher < ::EacRubyUtils::Console::DocoptRunner
9
9
  class Publish < ::EacLauncher::Instances::RunnerHelper
10
10
  DOC = <<~DOCOPT
@@ -1,17 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/docopt_runner'
4
- require 'eac_ruby_utils/core_ext'
5
3
  require 'avm/local_projects/instance'
4
+ require 'eac_cli/core_ext'
6
5
 
7
6
  module Avm
8
7
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
11
10
  require_sub __FILE__
12
- include ::EacCli::DefaultRunner
13
-
14
- runner_definition do
11
+ runner_with :help, :subcommands do
15
12
  desc 'Utilities for local projects.'
16
13
  arg_opt '-C', '--path', 'Path to local project instance.'
17
14
  subcommands
@@ -29,7 +26,7 @@ module Avm
29
26
  end
30
27
 
31
28
  def instance_path_uncached
32
- (options.fetch('--path') || '.').to_pathname.expand_path
29
+ (parsed.path || '.').to_pathname.expand_path
33
30
  end
34
31
  end
35
32
  end
@@ -6,14 +6,13 @@ require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
- class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
+ class LocalProject
11
+ class EacWritingsBase0
12
12
  require_sub __FILE__
13
- runner_with
14
13
  enable_simple_cache
15
14
 
16
- runner_definition do
15
+ runner_with :help, :subcommands do
17
16
  desc 'EacWritingsBase0 utitilies for local projects.'
18
17
  subcommands
19
18
  end
@@ -26,7 +25,7 @@ module Avm
26
25
  private
27
26
 
28
27
  def project_uncached
29
- ::Avm::EacWritingsBase0::Project.new(context(:instance_path))
28
+ ::Avm::EacWritingsBase0::Project.new(runner_context.call(:instance_path))
30
29
  end
31
30
  end
32
31
  end
@@ -6,13 +6,11 @@ require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
- class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
+ class LocalProject
11
+ class EacWritingsBase0
12
12
  class BuildChapters
13
- runner_with
14
-
15
- runner_definition do
13
+ runner_with :help do
16
14
  arg_opt '-o', '--output-dir', 'Output chapters to specific directory.'
17
15
  end
18
16
 
@@ -6,12 +6,11 @@ require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
- class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
+ class LocalProject
11
+ class EacWritingsBase0
12
12
  class BuildSingle
13
- runner_with
14
- runner_definition do
13
+ runner_with :help do
15
14
  arg_opt '-s', '--source-dir', 'Write .tex source code in specific directory.'
16
15
  arg_opt '-f', '--output-file', 'Output to specific file.'
17
16
  arg_opt '-c', '--chapter', 'Write only the chapter <chapter>.'
@@ -6,12 +6,11 @@ require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
- class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
+ class LocalProject
11
+ class EacWritingsBase0
12
12
  class Info
13
- runner_with
14
- runner_definition do
13
+ runner_with :help do
15
14
  desc 'Information about a loca EacRailsBase0 local project.'
16
15
  end
17
16
 
@@ -5,8 +5,8 @@ require 'eac_ruby_utils/console/docopt_runner'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
10
10
  class EacWritingsBase1
11
11
  require_sub __FILE__
12
12
 
@@ -7,8 +7,8 @@ require 'eac_ruby_utils/console/docopt_runner'
7
7
 
8
8
  module Avm
9
9
  module Tools
10
- class Runner < ::EacRubyUtils::Console::DocoptRunner
11
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Runner
11
+ class LocalProject
12
12
  class EacWritingsBase1
13
13
  class Build
14
14
  runner_with :help do
@@ -5,8 +5,8 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
10
10
  class Info < ::EacRubyUtils::Console::DocoptRunner
11
11
  include ::EacCli::DefaultRunner
12
12
 
@@ -7,8 +7,8 @@ require 'eac_ruby_utils/core_ext'
7
7
 
8
8
  module Avm
9
9
  module Tools
10
- class Runner < ::EacRubyUtils::Console::DocoptRunner
11
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Runner
11
+ class LocalProject
12
12
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
13
13
  require_sub __FILE__
14
14
  include ::EacCli::DefaultRunner
@@ -6,8 +6,8 @@ require 'eac_ruby_utils/core_ext'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
+ class LocalProject
11
11
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
12
12
  class Bundler < ::EacRubyUtils::Console::DocoptRunner
13
13
  require_sub __FILE__
@@ -5,8 +5,8 @@ require 'eac_ruby_utils/console/docopt_runner'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
10
10
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
11
11
  class Bundler < ::EacRubyUtils::Console::DocoptRunner
12
12
  class GemfileLock < ::EacRubyUtils::Console::DocoptRunner
@@ -5,8 +5,8 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
10
10
  class Test < ::EacRubyUtils::Console::DocoptRunner
11
11
  include ::EacCli::DefaultRunner
12
12
 
@@ -5,8 +5,8 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
+ class LocalProject
10
10
  class Update < ::EacRubyUtils::Console::DocoptRunner
11
11
  include ::EacCli::DefaultRunner
12
12
 
@@ -1,17 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/version'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
- require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/core_ext'
6
5
 
7
6
  module Avm
8
7
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
- class VersionBump < ::EacRubyUtils::Console::DocoptRunner
12
- include ::EacCli::DefaultRunner
13
-
14
- runner_definition do
8
+ class Runner
9
+ class LocalProject
10
+ class VersionBump
11
+ runner_with :help do
15
12
  desc 'Bump version of a local project.'
16
13
  arg_opt '-n', '--new', 'Set new version.'
17
14
  arg_opt '-s', '--segment', 'Increment de <segment>-th segment (Left-most is 0)'
@@ -29,7 +26,7 @@ module Avm
29
26
  def run_version_changed
30
27
  infom 'Version changed'
31
28
  if confirm?
32
- context(:instance).run_job(:version_bump, target_version)
29
+ runner_context.call(:instance).run_job(:version_bump, target_version)
33
30
  success 'Bumped'
34
31
  else
35
32
  fatal_error 'Bump unconfirmed'
@@ -41,23 +38,23 @@ module Avm
41
38
  end
42
39
 
43
40
  def start_banner
44
- context(:instance_banner)
41
+ runner_context.call(:instance_banner)
45
42
  infov 'Current version', current_version.if_present('-')
46
43
  infov 'Target version', target_version.if_present('-')
47
44
  end
48
45
 
49
46
  def confirm?
50
- options.fetch('--yes') || request_input('Confirm version bump?', bool: true)
47
+ parsed.yes? || request_input('Confirm version bump?', bool: true)
51
48
  end
52
49
 
53
50
  def current_version_uncached
54
- context(:instance).if_respond('version')
51
+ runner_context.call(:instance).if_respond('version')
55
52
  end
56
53
 
57
54
  def target_version_uncached
58
55
  r = current_version
59
56
  %w[new segment major minor patch].each do |option|
60
- option_value = options.fetch("--#{option}")
57
+ option_value = parsed[option]
61
58
  next if option_value.blank?
62
59
 
63
60
  r = send("target_version_from_#{option}", r, option_value)
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
9
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
10
10
  require_sub __FILE__
11
11
 
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class Runner
9
9
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
10
10
  class Gems < ::EacRubyUtils::Console::DocoptRunner
11
11
  require_sub __FILE__
@@ -7,7 +7,7 @@ require 'eac_cli/default_runner'
7
7
 
8
8
  module Avm
9
9
  module Tools
10
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Runner
11
11
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
12
12
  class Gems < ::EacRubyUtils::Console::DocoptRunner
13
13
  class Generate < ::EacRubyUtils::Console::DocoptRunner
@@ -6,7 +6,7 @@ require 'eac_ruby_utils/core_ext'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
10
  class Ruby < ::EacRubyUtils::Console::DocoptRunner
11
11
  class Rubocop < ::EacRubyUtils::Console::DocoptRunner
12
12
  include ::EacRubyUtils::Console::Speaker
@@ -6,7 +6,7 @@ require 'avm/self'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Runner
10
10
  class Self < ::EacRubyUtils::Console::DocoptRunner
11
11
  ::EacRubyUtils.require_sub(__FILE__)
12
12
 
@@ -4,7 +4,7 @@ require 'avm/docker/runner'
4
4
 
5
5
  module Avm
6
6
  module Tools
7
- class Runner < ::EacRubyUtils::Console::DocoptRunner
7
+ class Runner
8
8
  class Self < ::EacRubyUtils::Console::DocoptRunner
9
9
  class Docker < ::Avm::Docker::Runner
10
10
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.83.0'
5
+ VERSION = '0.87.0'
6
6
  end
7
7
  end
@@ -1,12 +1,13 @@
1
1
  default: &default
2
2
  adapter: %%DATABASE.SYSTEM%%
3
- pool: 40
4
- timeout: 5000
3
+ pool: %%DATABASE.LIMIT%%
4
+ timeout: %%DATABASE.TIMEOUT%%
5
5
  encoding: unicode
6
6
  username: %%DATABASE.USERNAME%%
7
7
  password: %%DATABASE.PASSWORD%%
8
8
  host: %%DATABASE.HOSTNAME%%
9
9
  port: %%DATABASE.PORT%%
10
+ reconnect: true
10
11
 
11
12
  development: &development
12
13
  <<: *default
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module Docopt
7
+ class RunnerContextReplacement
8
+ common_constructor :runner
9
+
10
+ def argv
11
+ runner.settings[:argv] || ARGV
12
+ end
13
+ end
14
+ end
15
+ end
@@ -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
- if argv_current_option?
39
- option_collect_argv_value
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