avm-tools 0.76.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- 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/lib/eac_cli/definition.rb +34 -39
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
- 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/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/runner.rb +2 -2
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
- 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 +10 -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 +14 -5
- 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 +59 -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/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
- metadata +16 -5
- data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
@@ -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)
|
@@ -84,7 +84,7 @@ module EacCli
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def parsed
|
87
|
-
@parsed ||= ::EacCli::Parser.new(self.class.runner_definition
|
87
|
+
@parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
|
88
88
|
end
|
89
89
|
end
|
90
90
|
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
|
@@ -23,9 +23,14 @@ RSpec.describe ::EacCli::Runner do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
let(:instance) { runner_class.create(argv) }
|
27
|
+
let(:parsed_actual) { instance.parsed.to_h.symbolize_keys }
|
28
|
+
|
26
29
|
context 'when all args are supplied' do
|
27
|
-
let(:
|
30
|
+
let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
|
31
|
+
let(:parsed_expected) { { opt1: 'aaa', opt2: true, pos1: 'bbb', pos2: %w[ccc ddd] } }
|
28
32
|
|
33
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
29
34
|
it { expect(instance.parsed.opt1).to eq('aaa') }
|
30
35
|
it { expect(instance.parsed.opt2?).to eq(true) }
|
31
36
|
it { expect(instance.parsed.pos1).to eq('bbb') }
|
@@ -33,8 +38,10 @@ RSpec.describe ::EacCli::Runner do
|
|
33
38
|
end
|
34
39
|
|
35
40
|
context 'when only required args are supplied' do
|
36
|
-
let(:
|
41
|
+
let(:argv) { %w[bbb] }
|
42
|
+
let(:parsed_expected) { { opt1: nil, opt2: false, pos1: 'bbb', pos2: [] } }
|
37
43
|
|
44
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
38
45
|
it { expect(instance.parsed.opt1).to be_nil }
|
39
46
|
it { expect(instance.parsed.opt2?).to eq(false) }
|
40
47
|
it { expect(instance.parsed.pos1).to eq('bbb') }
|
@@ -42,7 +49,7 @@ RSpec.describe ::EacCli::Runner do
|
|
42
49
|
end
|
43
50
|
|
44
51
|
context 'when required args are not supplied' do
|
45
|
-
let(:
|
52
|
+
let(:argv) { %w[] }
|
46
53
|
|
47
54
|
it do
|
48
55
|
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
@@ -50,8 +57,10 @@ RSpec.describe ::EacCli::Runner do
|
|
50
57
|
end
|
51
58
|
|
52
59
|
context 'when alternative args are supplied' do
|
53
|
-
let(:
|
60
|
+
let(:argv) { %w[--opt3] }
|
61
|
+
let(:parsed_expected) { { opt3: true } }
|
54
62
|
|
63
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
55
64
|
it { expect(instance.parsed.opt3?).to eq(true) }
|
56
65
|
end
|
57
66
|
|
@@ -69,7 +78,7 @@ RSpec.describe ::EacCli::Runner do
|
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
72
|
-
let(:
|
81
|
+
let(:argv) { %w[aaa bbb] }
|
73
82
|
|
74
83
|
it do
|
75
84
|
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
@@ -1,12 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/filesystem_cache'
|
4
5
|
|
5
6
|
module EacRubyBase0
|
6
7
|
class Application
|
7
8
|
enable_simple_cache
|
8
|
-
|
9
|
+
enable_listable
|
10
|
+
lists.add_symbol :option, :name, :home_dir
|
11
|
+
|
12
|
+
common_constructor :gemspec_dir, :options, default: [{}] do
|
9
13
|
self.gemspec_dir = gemspec_dir.to_pathname
|
14
|
+
self.options = options.symbolize_keys.assert_valid_keys(self.class.lists.option.values).freeze
|
10
15
|
end
|
11
16
|
|
12
17
|
delegate :version, to: :self_gem
|
@@ -15,6 +20,32 @@ module EacRubyBase0
|
|
15
20
|
vendor_gems + [self_gem]
|
16
21
|
end
|
17
22
|
|
23
|
+
{ cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
|
24
|
+
xdg_env_method_name = "#{item}_xdg_env"
|
25
|
+
|
26
|
+
define_method xdg_env_method_name do
|
27
|
+
ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
|
28
|
+
end
|
29
|
+
|
30
|
+
define_method "#{item}_dir" do
|
31
|
+
(send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def fs_cache
|
36
|
+
@fs_cache ||= ::EacRubyUtils::FilesystemCache.new(
|
37
|
+
cache_dir.join(::EacRubyUtils::FilesystemCache.name.parameterize)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def home_dir
|
42
|
+
@home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
|
43
|
+
end
|
44
|
+
|
45
|
+
def name
|
46
|
+
options[OPTION_NAME] || self_gem.name
|
47
|
+
end
|
48
|
+
|
18
49
|
def vendor_dir
|
19
50
|
gemspec_dir.join('vendor')
|
20
51
|
end
|