avm-tools 0.76.1 → 0.81.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  3. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  4. data/lib/avm/patches/class/i18n.rb +31 -0
  5. data/lib/avm/patches/object/i18n.rb +2 -10
  6. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
  7. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
  8. data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
  9. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  10. data/lib/avm/tools/version.rb +1 -1
  11. data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
  12. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  13. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  14. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  15. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  16. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  17. data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
  18. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
  19. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  20. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  21. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  22. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  23. data/vendor/eac_cli/lib/eac_cli/runner.rb +12 -4
  24. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  25. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +16 -1
  26. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  27. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  29. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  30. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  31. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  32. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +17 -5
  33. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  34. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  35. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -1
  36. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
  37. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
  38. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  48. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  49. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  50. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  51. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  52. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  53. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  54. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  56. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  57. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  58. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  59. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  60. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  61. metadata +28 -7
  62. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  63. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
  64. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  65. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  66. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/argument_option'
4
+ require 'eac_cli/definition/boolean_option'
5
+ require 'eac_cli/definition/positional_argument'
6
+
7
+ module EacCli
8
+ class Definition
9
+ class Alternative
10
+ SUBCOMMAND_NAME_ARG = :subcommand
11
+ SUBCOMMAND_ARGS_ARG = :subcommand_args
12
+
13
+ def arg_opt(short, long, description, option_options = {})
14
+ options_set << ::EacCli::Definition::ArgumentOption.new(
15
+ short, long, description, option_options
16
+ )
17
+ end
18
+
19
+ def bool_opt(short, long, description, option_options = {})
20
+ options_set << ::EacCli::Definition::BooleanOption.new(short, long, description,
21
+ option_options)
22
+ end
23
+
24
+ def options
25
+ options_set.to_a
26
+ end
27
+
28
+ def options_argument?
29
+ @options_argument ? true : false
30
+ end
31
+
32
+ def options_argument(enable)
33
+ @options_argument = enable
34
+
35
+ self
36
+ end
37
+
38
+ def pos_arg(name, arg_options = {})
39
+ new_pos_arg = ::EacCli::Definition::PositionalArgument.new(name, arg_options)
40
+ check_positional_blocked(new_pos_arg)
41
+ pos_set << new_pos_arg
42
+ end
43
+
44
+ def positional
45
+ pos_set.to_a
46
+ end
47
+
48
+ def positional_arguments_blocked?(new_pos_arg)
49
+ last = pos_set.last
50
+ return false unless last
51
+ return true if subcommands?
52
+ return true if last.repeat?
53
+ return true if last.optional? && new_pos_arg.if_present(&:required?)
54
+
55
+ false
56
+ end
57
+
58
+ def subcommands
59
+ pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
60
+ pos_set << ::EacCli::Definition::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
61
+ optional: true, repeat: true)
62
+ end
63
+
64
+ def subcommands?
65
+ pos_set.any?(&:subcommand?)
66
+ end
67
+
68
+ private
69
+
70
+ def check_positional_blocked(new_pos_arg)
71
+ raise 'Positional arguments are blocked' if positional_arguments_blocked?(new_pos_arg)
72
+ end
73
+
74
+ def pos_set
75
+ @pos_set ||= []
76
+ end
77
+
78
+ def options_set
79
+ @options_set ||= []
80
+ end
81
+ end
82
+ end
83
+ end
@@ -6,71 +6,49 @@ require 'eac_ruby_utils/console/docopt_runner'
6
6
  module EacCli
7
7
  module Docopt
8
8
  class DocBuilder
9
+ require_sub __FILE__
9
10
  common_constructor :definition
10
11
 
11
12
  SEP = ' '
12
13
  IDENT = SEP * 2
13
14
  OPTION_DESC_SEP = IDENT * 2
14
15
 
15
- def positional_argument(positional)
16
- if positional.subcommand?
17
- ::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
18
- else
19
- r = "<#{positional.name}>"
20
- r += '...' if positional.repeat?
21
- r = "[#{r}]" if positional.optional?
22
- r
16
+ class << self
17
+ def option_long(option)
18
+ b = option.long
19
+ b += '=<value>' if option.argument?
20
+ b
23
21
  end
24
22
  end
25
23
 
26
- def option_argument(option)
27
- option_long(option)
28
- end
29
-
30
24
  def option_definition(option)
31
- option.short + SEP + option_long(option) + OPTION_DESC_SEP + option.description
32
- end
33
-
34
- def option_long(option)
35
- b = option.long
36
- b += '=<value>' if option.argument?
37
- b
25
+ option.short + SEP + self.class.option_long(option) + OPTION_DESC_SEP + option.description
38
26
  end
39
27
 
40
28
  def section(header, include_header = true)
41
29
  b = include_header ? "#{header.humanize}:\n" : ''
42
30
  b += send("self_#{header}") + "\n"
43
31
  definition.alternatives.each do |alternative|
44
- b += self.class.new(alternative).section(header, false)
32
+ b += IDENT + ::EacCli::Docopt::DocBuilder::Alternative.new(alternative).to_s + "\n"
45
33
  end
46
34
  b
47
35
  end
48
36
 
49
- def self_options
50
- definition.options.map { |option| IDENT + option_definition(option) }.join("\n")
51
- end
52
-
53
- def self_usage
54
- IDENT + self_usage_arguments.join(SEP)
55
- end
56
-
57
- def self_usage_arguments
58
- [::EacRubyUtils::Console::DocoptRunner::PROGRAM_MACRO] +
59
- definition.options_argument.if_present([]) { |_v| ['[options]'] } +
60
- self_usage_arguments_options +
61
- self_usage_arguments_positional
62
- end
63
-
64
- def self_usage_arguments_options
65
- definition.options.select(&:show_on_usage?).map { |option| option_argument(option) }
37
+ def options_section
38
+ "Options:\n" +
39
+ definition.alternatives.flat_map(&:options)
40
+ .map { |option| IDENT + option_definition(option) + "\n" }.join
66
41
  end
67
42
 
68
- def self_usage_arguments_positional
69
- definition.positional.map { |p| positional_argument(p) }
43
+ def usage_section
44
+ "Usage:\n" +
45
+ definition.alternatives.map do |alternative|
46
+ IDENT + ::EacCli::Docopt::DocBuilder::Alternative.new(alternative).to_s + "\n"
47
+ end.join
70
48
  end
71
49
 
72
50
  def to_s
73
- "#{definition.description}\n\n#{section('usage')}\n#{section('options')}\n"
51
+ "#{definition.description}\n\n#{usage_section}\n#{options_section}\n"
74
52
  end
75
53
  end
76
54
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module EacCli
7
+ module Docopt
8
+ class DocBuilder
9
+ class Alternative
10
+ common_constructor :alternative
11
+
12
+ def to_s
13
+ (
14
+ [::EacRubyUtils::Console::DocoptRunner::PROGRAM_MACRO] +
15
+ alternative.options_argument?.if_present([]) { |_v| ['[options]'] } +
16
+ options +
17
+ positionals
18
+ ).join(::EacCli::Docopt::DocBuilder::SEP)
19
+ end
20
+
21
+ def options
22
+ alternative.options.select(&:show_on_usage?).map do |option|
23
+ ::EacCli::Docopt::DocBuilder.option_long(option)
24
+ end
25
+ end
26
+
27
+ def option_argument(option)
28
+ b = option.long
29
+ b += '=<value>' if option.argument?
30
+ b
31
+ end
32
+
33
+ def positionals
34
+ alternative.positional.map { |p| positional(p) }
35
+ end
36
+
37
+ def positional(positional)
38
+ if positional.subcommand?
39
+ ::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
40
+ else
41
+ r = "<#{positional.name}>"
42
+ r += '...' if positional.repeat?
43
+ r = "[#{r}]" if positional.optional?
44
+ r
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -5,10 +5,30 @@ require 'eac_ruby_utils/core_ext'
5
5
  module EacCli
6
6
  class Parser
7
7
  require_sub __FILE__
8
- common_constructor :definition
8
+ enable_simple_cache
9
+ common_constructor :definition, :argv
9
10
 
10
- def parse(argv)
11
- ::EacCli::Parser::ParseResult.new(definition, argv).result
11
+ private
12
+
13
+ def parsed_uncached
14
+ raise 'Definition has no alternatives' if alternatives.empty?
15
+ raise first_error unless alternatives.select(&:success?).any?
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
12
32
  end
13
33
  end
14
34
  end
@@ -0,0 +1,92 @@
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
+ attr_reader :error
14
+
15
+ common_constructor :alternative, :argv do
16
+ alternative.assert_argument(::EacCli::Definition::Alternative, :alternative)
17
+ self.phase = PHASE_ANY
18
+ collect
19
+ end
20
+
21
+ def error?
22
+ error.present?
23
+ end
24
+
25
+ def success?
26
+ !error?
27
+ end
28
+
29
+ def parsed
30
+ @parsed ||= collector.to_data.freeze
31
+ end
32
+
33
+ private
34
+
35
+ attr_accessor :phase
36
+
37
+ def any_collect_argv_value
38
+ if argv_current_option?
39
+ option_collect_argv_value
40
+ else
41
+ positional_collect_argv_value
42
+ end
43
+ end
44
+
45
+ def collector
46
+ @collector ||= ::EacCli::Parser::Collector.new(alternative)
47
+ end
48
+
49
+ def collect
50
+ loop do
51
+ break unless argv_pending?
52
+
53
+ collect_argv_value
54
+ end
55
+ validate
56
+ rescue ::EacCli::Parser::Error => e
57
+ @error = e
58
+ end
59
+
60
+ def collect_argv_value
61
+ send("#{phase}_collect_argv_value")
62
+ argv_enum.next
63
+ end
64
+
65
+ def collect_option_argv_value
66
+ alternative.options.each do |option|
67
+ end
68
+
69
+ raise ::EacCli::Parser::Error.new(
70
+ alternative, argv, "Invalid option: #{argv_enum.current}"
71
+ )
72
+ end
73
+
74
+ def raise_error(message)
75
+ raise ::EacCli::Parser::Error.new(alternative, argv, message)
76
+ end
77
+
78
+ def validate
79
+ (alternative.options + alternative.positional).each do |option|
80
+ validate_option(option)
81
+ end
82
+ end
83
+
84
+ def validate_option(option)
85
+ return unless option.required?
86
+ return if collector.supplied?(option)
87
+
88
+ raise_error("Required option/positional #{option} not supplied")
89
+ end
90
+ end
91
+ end
92
+ end
@@ -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