avm-tools 0.75.1 → 0.79.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/files/formatter.rb +8 -4
- data/lib/avm/git/auto_commit_path.rb +2 -4
- data/lib/avm/git/auto_commit_path/ruby.rb +20 -0
- data/lib/avm/patches/class/i18n.rb +31 -0
- data/lib/avm/patches/object/i18n.rb +2 -10
- data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
- data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
- data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +7 -16
- data/lib/avm/tools/runner/files/format.rb +3 -2
- data/lib/avm/tools/runner/git/auto_commit.rb +11 -0
- data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition.rb +49 -22
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
- data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb} +20 -49
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +1 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner.rb +6 -2
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +96 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +35 -0
- data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +57 -40
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +57 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -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 +3 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
- metadata +31 -5
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -21
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -49
@@ -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
|
@@ -5,19 +5,35 @@ require 'eac_ruby_utils/core_ext'
|
|
5
5
|
module EacCli
|
6
6
|
class Definition
|
7
7
|
class BaseOption
|
8
|
+
DEFAULT_REQUIRED = false
|
9
|
+
|
10
|
+
enable_listable
|
11
|
+
lists.add_symbol :option, :optional, :usage, :required
|
8
12
|
attr_reader :short, :long, :description, :options
|
9
13
|
|
10
14
|
def initialize(short, long, description, options = {})
|
11
15
|
@short = short
|
12
16
|
@long = long
|
13
17
|
@description = description
|
14
|
-
@options = options.
|
18
|
+
@options = options.symbolize_keys
|
19
|
+
@options.assert_valid_keys(::EacCli::Definition::BaseOption.lists.option.values)
|
15
20
|
end
|
16
21
|
|
17
22
|
def identifier
|
18
23
|
long.to_s.variableize.to_sym
|
19
24
|
end
|
20
25
|
|
26
|
+
def required?
|
27
|
+
return true if options.key?(:required) && options.fetch(:required)
|
28
|
+
return false if options.key?(:optional) && options.fetch(:optional)
|
29
|
+
|
30
|
+
DEFAULT_REQUIRED
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
"#{self.class.name.demodulize}[#{identifier}]"
|
35
|
+
end
|
36
|
+
|
21
37
|
def show_on_usage?
|
22
38
|
options[:usage]
|
23
39
|
end
|
data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb}
RENAMED
@@ -1,49 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'optparse'
|
5
4
|
|
6
5
|
module EacCli
|
7
|
-
class
|
8
|
-
class
|
6
|
+
class Definition
|
7
|
+
class HelpFormatter
|
9
8
|
SEP = ' '
|
10
9
|
IDENT = SEP * 2
|
11
10
|
OPTION_DESC_SEP = IDENT * 2
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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)
|
12
|
+
class << self
|
13
|
+
def option_long(option)
|
14
|
+
b = option.long
|
15
|
+
b += '=VALUE' if option.argument?
|
16
|
+
b
|
36
17
|
end
|
37
|
-
end
|
38
18
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
collector.collect(option, value)
|
19
|
+
def option_short(option)
|
20
|
+
b = option.short
|
21
|
+
b += 'VALUE' if option.argument?
|
22
|
+
b
|
44
23
|
end
|
45
24
|
end
|
46
25
|
|
26
|
+
common_constructor :definition
|
27
|
+
|
47
28
|
def positional_argument(positional)
|
48
29
|
if positional.subcommand?
|
49
30
|
::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
|
@@ -55,22 +36,6 @@ module EacCli
|
|
55
36
|
end
|
56
37
|
end
|
57
38
|
|
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
39
|
def section(header, include_header = true)
|
75
40
|
b = include_header ? "#{header.humanize}:\n" : ''
|
76
41
|
b += send("self_#{header}") + "\n"
|
@@ -94,12 +59,18 @@ module EacCli
|
|
94
59
|
end
|
95
60
|
|
96
61
|
def self_usage_arguments_options
|
97
|
-
definition.options.select(&:show_on_usage?).map
|
62
|
+
definition.options.select(&:show_on_usage?).map do |option|
|
63
|
+
self.class.option_long(option)
|
64
|
+
end
|
98
65
|
end
|
99
66
|
|
100
67
|
def self_usage_arguments_positional
|
101
68
|
definition.positional.map { |p| positional_argument(p) }
|
102
69
|
end
|
70
|
+
|
71
|
+
def to_banner
|
72
|
+
"#{definition.description}\n\n#{section('usage')}"
|
73
|
+
end
|
103
74
|
end
|
104
75
|
end
|
105
76
|
end
|
@@ -5,22 +5,39 @@ require 'eac_ruby_utils/core_ext'
|
|
5
5
|
module EacCli
|
6
6
|
class Definition
|
7
7
|
class PositionalArgument
|
8
|
-
|
8
|
+
DEFAULT_REQUIRED = true
|
9
|
+
|
10
|
+
enable_listable
|
11
|
+
lists.add_symbol :option, :optional, :repeat, :required, :subcommand
|
12
|
+
common_constructor :name, :options, default: [{}] do
|
13
|
+
options.assert_valid_keys(self.class.lists.option.values)
|
14
|
+
end
|
9
15
|
|
10
16
|
def identifier
|
11
17
|
name.to_s.variableize.to_sym
|
12
18
|
end
|
13
19
|
|
14
20
|
def optional?
|
15
|
-
|
21
|
+
!required?
|
16
22
|
end
|
17
23
|
|
18
24
|
def repeat?
|
19
|
-
options[
|
25
|
+
options[OPTION_REPEAT]
|
26
|
+
end
|
27
|
+
|
28
|
+
def required?
|
29
|
+
return true if options.key?(OPTION_REQUIRED) && options.fetch(OPTION_REQUIRED)
|
30
|
+
return false if options.key?(OPTION_OPTIONAL) && options.fetch(OPTION_OPTIONAL)
|
31
|
+
|
32
|
+
DEFAULT_REQUIRED
|
20
33
|
end
|
21
34
|
|
22
35
|
def subcommand?
|
23
|
-
options[
|
36
|
+
options[OPTION_SUBCOMMAND]
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
"#{self.class.name.demodulize}[#{identifier}]"
|
24
41
|
end
|
25
42
|
end
|
26
43
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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 +=
|
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
|
50
|
-
|
51
|
-
|
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
|
69
|
-
|
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#{
|
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,28 @@ require 'eac_ruby_utils/core_ext'
|
|
5
5
|
module EacCli
|
6
6
|
class Parser
|
7
7
|
require_sub __FILE__
|
8
|
-
|
8
|
+
enable_simple_cache
|
9
|
+
common_constructor :definition, :argv
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
private
|
12
|
+
|
13
|
+
def parsed_uncached
|
14
|
+
raise 'Definition has no alternatives' if alternatives.empty?
|
15
|
+
|
16
|
+
alternatives.each do |alt_parser|
|
17
|
+
return alt_parser.parsed unless alt_parser.error?
|
18
|
+
end
|
19
|
+
|
20
|
+
raise first_error
|
21
|
+
end
|
22
|
+
|
23
|
+
def alternatives_uncached
|
24
|
+
definition.alternatives
|
25
|
+
.map { |alternative| ::EacCli::Parser::Alternative.new(alternative, argv) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def first_error_uncached
|
29
|
+
alternatives.lazy.select(&:error?).map(&:error).first
|
12
30
|
end
|
13
31
|
end
|
14
32
|
end
|