avm-tools 0.91.0 → 0.92.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/git/auto_commit/commit_info.rb +22 -0
- data/lib/avm/git/auto_commit/rules.rb +31 -0
- data/lib/avm/git/auto_commit/rules/base.rb +39 -0
- data/lib/avm/git/auto_commit/rules/last.rb +19 -0
- data/lib/avm/git/auto_commit/rules/manual.rb +45 -0
- data/lib/avm/git/auto_commit/rules/nth.rb +23 -0
- data/lib/avm/git/auto_commit/rules/unique.rb +21 -0
- data/lib/avm/git/file_auto_fixup.rb +15 -62
- data/lib/avm/tools/runner/git/auto_commit.rb +12 -13
- data/lib/avm/tools/runner/git/auto_fixup.rb +9 -9
- data/lib/avm/tools/runner/git/commit.rb +11 -20
- data/lib/avm/tools/version.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +6 -1
- 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/parser/collector.rb +3 -17
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +21 -3
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b6568f1c571107315662a90e29d111bf1af9a534c326ea57f358fa68c7ec550
|
4
|
+
data.tar.gz: 808a16008057b72ef58b11d91f05e021c814bca2100f3c5e85c0363bcac97216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc0628987c36f9c72d642546a7b4ab85e3c630a239e053af92beb86658deac8fba9c7e389947b843097499fce529d2b100d734173aad36dea200d5c874a61ef8
|
7
|
+
data.tar.gz: c3b19cbf0a2d063e5a436d314b5b20ab7167e584bca986c486e6ee2fd9beccfcd156e0d7095559caf0fd4236f279aeea91a81cb45207cd5b01f769e2987c85b4
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
class CommitInfo
|
9
|
+
enable_immutable
|
10
|
+
|
11
|
+
immutable_accessor :fixup
|
12
|
+
|
13
|
+
def git_commit_args
|
14
|
+
r = fixup.if_present([]) { |v| ['--fixup', v.sha1] }
|
15
|
+
return r if r.any?
|
16
|
+
|
17
|
+
raise 'Argument list is empty'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
require_sub __FILE__
|
10
|
+
|
11
|
+
RULES_CLASSES = %w[last manual nth unique]
|
12
|
+
.map { |key| ::Avm::Git::AutoCommit::Rules.const_get(key.camelcase) }
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def parse(string)
|
16
|
+
parts = string.split(':')
|
17
|
+
|
18
|
+
klass = rule_class_by_key(parts.shift)
|
19
|
+
klass.new(*parts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def rule_class_by_key(key)
|
23
|
+
RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
|
24
|
+
raise("Rule not find with key \"#{key}\" (Available: " +
|
25
|
+
RULES_CLASSES.flat_map(&:keys) + ')')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
class Base
|
10
|
+
class << self
|
11
|
+
def keys
|
12
|
+
[long_key, short_key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def long_key
|
16
|
+
name.demodulize.variableize
|
17
|
+
end
|
18
|
+
|
19
|
+
def short_key
|
20
|
+
long_key[0, 1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def with_file(file)
|
25
|
+
self.class.const_get('WithFile').new(self, file)
|
26
|
+
end
|
27
|
+
|
28
|
+
class WithFile
|
29
|
+
common_constructor :rule, :file
|
30
|
+
|
31
|
+
def new_commit_info
|
32
|
+
::Avm::Git::AutoCommit::CommitInfo.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/auto_commit/rules/base'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
class Last < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
+
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
+
def commit_info
|
12
|
+
file.commits.last.if_present { |v| new_commit_info.fixup(v) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/auto_commit/rules/base'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
class Manual < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
+
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
+
enable_console_speaker
|
12
|
+
|
13
|
+
COMMIT_FORMAT = '%h - %s (%cr)'
|
14
|
+
SKIP_OPTION = 's'
|
15
|
+
|
16
|
+
def commit_info
|
17
|
+
return nil unless file.commits.any?
|
18
|
+
|
19
|
+
commits_banner
|
20
|
+
request_input('Which commit?', list: commits_by_position).if_present do |v|
|
21
|
+
new_commit_info.fixup(v)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def commits_banner
|
26
|
+
file.commits.each_with_index do |commit, _index|
|
27
|
+
infov " #{commit.position}", format_commit(commit)
|
28
|
+
end
|
29
|
+
infov " #{SKIP_OPTION}", 'skip'
|
30
|
+
end
|
31
|
+
|
32
|
+
def commits_by_position
|
33
|
+
(file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]])
|
34
|
+
.to_h
|
35
|
+
end
|
36
|
+
|
37
|
+
def format_commit(commit)
|
38
|
+
commit.format(COMMIT_FORMAT)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/auto_commit/rules/base'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
class Nth < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
+
common_constructor :number do
|
11
|
+
self.number = number.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
15
|
+
def commit_info
|
16
|
+
file.commits(number - 1).if_present { |v| new_commit_info.fixup(v) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/auto_commit/rules/base'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module AutoCommit
|
8
|
+
module Rules
|
9
|
+
class Unique < ::Avm::Git::AutoCommit::Rules::Base
|
10
|
+
class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
|
11
|
+
def commit_info
|
12
|
+
return nil unless file.commits.count == 1
|
13
|
+
|
14
|
+
new_commit_info.fixup(file.commits.first)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/git/auto_commit/commit_info'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module Avm
|
@@ -8,31 +9,24 @@ module Avm
|
|
8
9
|
enable_console_speaker
|
9
10
|
enable_simple_cache
|
10
11
|
enable_listable
|
11
|
-
lists.add_symbol :option, :select, :unique
|
12
12
|
|
13
|
-
common_constructor :git, :path, :
|
14
|
-
self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
|
15
|
-
end
|
13
|
+
common_constructor :git, :path, :rules
|
16
14
|
|
17
|
-
COMMIT_FORMAT = '%h - %s (%cr)'
|
18
15
|
COMMITS_SEARCH_INTERVAL = 'origin/master..HEAD'
|
19
|
-
SKIP_OPTION = 's'
|
20
16
|
|
21
17
|
def run
|
22
18
|
start_banner
|
23
|
-
|
24
|
-
run_no_commits_found
|
25
|
-
elsif auto_selected_commit.present?
|
26
|
-
fixup_commit(auto_selected_commit)
|
27
|
-
else
|
28
|
-
run_commits_selection
|
29
|
-
end
|
19
|
+
run_commit || warn("No rule returned commit information for \"#{path}\"")
|
30
20
|
end
|
31
21
|
|
32
22
|
private
|
33
23
|
|
34
|
-
def
|
35
|
-
|
24
|
+
def commit_args
|
25
|
+
commit_info.if_present([], &:git_commit_args) + ['--', path]
|
26
|
+
end
|
27
|
+
|
28
|
+
def commit_info_uncached
|
29
|
+
rules.lazy.map { |rule| rule.with_file(self).commit_info }.find(&:present?)
|
36
30
|
end
|
37
31
|
|
38
32
|
def start_banner
|
@@ -40,50 +34,13 @@ module Avm
|
|
40
34
|
infov ' Commits found', commits.count
|
41
35
|
end
|
42
36
|
|
43
|
-
def
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def fixup_commit(commit)
|
48
|
-
infov ' Commit selected/found', format_commit(commit)
|
49
|
-
git.execute!('commit', '--fixup', commit.sha1, '--', path)
|
50
|
-
success " Fixup with \"#{format_commit(commit)}\""
|
51
|
-
end
|
52
|
-
|
53
|
-
def run_commits_selection
|
54
|
-
selected_commit = select_commit
|
55
|
-
if selected_commit
|
56
|
-
fixup_commit(selected_commit)
|
57
|
-
else
|
58
|
-
infom ' Skipped'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def select_commit
|
63
|
-
commits_banner
|
64
|
-
request_input('Which commit?', list: commits_by_position)
|
65
|
-
end
|
66
|
-
|
67
|
-
def selected_commit_by_unique
|
68
|
-
return unless options[OPTION_UNIQUE]
|
69
|
-
return commits.first if commits.first
|
70
|
-
end
|
37
|
+
def run_commit
|
38
|
+
return false if commit_info.blank?
|
71
39
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
def commits_banner
|
79
|
-
commits.each_with_index do |commit, _index|
|
80
|
-
infov " #{commit.position}", format_commit(commit)
|
81
|
-
end
|
82
|
-
infov " #{SKIP_OPTION}", 'skip'
|
83
|
-
end
|
84
|
-
|
85
|
-
def commits_by_position
|
86
|
-
(commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]]).to_h
|
40
|
+
infov ' Commit arguments', ::Shellwords.join(commit_args)
|
41
|
+
git.execute!('commit', *commit_args)
|
42
|
+
success ' Commited'
|
43
|
+
true
|
87
44
|
end
|
88
45
|
|
89
46
|
def commits_uncached
|
@@ -93,10 +50,6 @@ module Avm
|
|
93
50
|
.each_with_index.map { |commit, index| CommitDelegator.new(commit, index) }
|
94
51
|
end
|
95
52
|
|
96
|
-
def format_commit(commit)
|
97
|
-
commit.format(COMMIT_FORMAT)
|
98
|
-
end
|
99
|
-
|
100
53
|
class CommitDelegator < ::SimpleDelegator
|
101
54
|
attr_reader :index
|
102
55
|
|
@@ -2,16 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'avm/git/auto_commit_path'
|
4
4
|
require 'avm/files/formatter'
|
5
|
-
require 'eac_cli/
|
5
|
+
require 'eac_cli/core_ext'
|
6
6
|
|
7
7
|
module Avm
|
8
8
|
module Tools
|
9
9
|
class Runner
|
10
10
|
class Git
|
11
|
-
class AutoCommit
|
12
|
-
|
13
|
-
|
14
|
-
runner_definition do
|
11
|
+
class AutoCommit
|
12
|
+
runner_with :help do
|
15
13
|
desc 'Commit with message based in content commited.'
|
16
14
|
bool_opt '-d', '--dirty', 'Select dirty files.'
|
17
15
|
bool_opt '-f', '--format', 'Format files before commit.'
|
@@ -33,17 +31,19 @@ module Avm
|
|
33
31
|
|
34
32
|
def clear_stage
|
35
33
|
infom 'Clearing stage...'
|
36
|
-
|
34
|
+
runner_context.call(:git).system!('reset', 'HEAD')
|
37
35
|
end
|
38
36
|
|
39
37
|
def dirty_paths
|
40
|
-
return [] unless
|
38
|
+
return [] unless parsed.dirty?
|
41
39
|
|
42
|
-
|
40
|
+
runner_context.call(:git).dirty_files.map do |d|
|
41
|
+
runner_context.call(:git).root_path.join / d.path
|
42
|
+
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def format_files
|
46
|
-
return unless
|
46
|
+
return unless parsed.format?
|
47
47
|
|
48
48
|
infom 'Formating files...'
|
49
49
|
::Avm::Files::Formatter.new(paths.map(&:path),
|
@@ -51,10 +51,9 @@ module Avm
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def paths_uncached
|
54
|
-
(
|
55
|
-
.
|
56
|
-
.
|
57
|
-
.sort.uniq.map { |path| ::Avm::Git::AutoCommitPath.new(context(:git), path) }
|
54
|
+
(parsed.paths.map { |p| p.to_pathname.expand_path } + dirty_paths)
|
55
|
+
.reject(&:directory?).sort.uniq
|
56
|
+
.map { |path| ::Avm::Git::AutoCommitPath.new(runner_context.call(:git), path) }
|
58
57
|
end
|
59
58
|
|
60
59
|
def run_paths
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'eac_cli/core_ext'
|
4
4
|
require 'eac_ruby_utils/console/docopt_runner'
|
5
5
|
require 'avm/git/file_auto_fixup'
|
6
|
+
require 'avm/git/auto_commit/rules'
|
6
7
|
|
7
8
|
module Avm
|
8
9
|
module Tools
|
@@ -11,25 +12,18 @@ module Avm
|
|
11
12
|
class AutoFixup
|
12
13
|
runner_with :help do
|
13
14
|
desc 'Auto fixup files.'
|
14
|
-
|
15
|
-
arg_opt '-s', '--select', 'Automatically select de <value>-th commit.'
|
16
|
-
bool_opt '-u', '--unique', 'Automatically select the first commit if it is unique.'
|
15
|
+
arg_opt '-r', '--rule', 'Apply a rule in the specified order.', repeat: true
|
17
16
|
pos_arg :files, repeat: true, optional: true
|
18
17
|
end
|
19
18
|
|
20
19
|
def run
|
21
20
|
files.each do |file|
|
22
|
-
::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file,
|
21
|
+
::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file, rules).run
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
|
-
def file_options
|
29
|
-
{ Avm::Git::FileAutoFixup::OPTION_SELECT => select,
|
30
|
-
Avm::Git::FileAutoFixup::OPTION_UNIQUE => parsed.unique? }
|
31
|
-
end
|
32
|
-
|
33
27
|
def files
|
34
28
|
files_from_option || dirty_files
|
35
29
|
end
|
@@ -43,6 +37,12 @@ module Avm
|
|
43
37
|
runner_context.call(:git).dirty_files.map(&:path)
|
44
38
|
end
|
45
39
|
|
40
|
+
def rules
|
41
|
+
parsed.rule.map do |rule_string|
|
42
|
+
::Avm::Git::AutoCommit::Rules.parse(rule_string)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
46
|
def select
|
47
47
|
parsed.last? ? 1 : parsed.select
|
48
48
|
end
|
@@ -11,22 +11,13 @@ module Avm
|
|
11
11
|
module Tools
|
12
12
|
class Runner
|
13
13
|
class Git
|
14
|
-
class Commit
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Usage:
|
22
|
-
__PROGRAM__ [options] <ref>
|
23
|
-
__PROGRAM__ -h | --help
|
24
|
-
|
25
|
-
Options:
|
26
|
-
-h --help Mostra esta ajuda.
|
27
|
-
-f --files Mostra os arquivos.
|
28
|
-
-s --size Mostra o tamanho de arquivos.
|
29
|
-
DOCOPT
|
14
|
+
class Commit
|
15
|
+
runner_with :help do
|
16
|
+
desc 'Mostra informações de um commit.'
|
17
|
+
bool_opt '-f', '--files', 'Mostra os arquivos.'
|
18
|
+
bool_opt '-s', '--size', 'Mostra o tamanho de arquivos.'
|
19
|
+
pos_arg :ref
|
20
|
+
end
|
30
21
|
|
31
22
|
def run
|
32
23
|
input_banner
|
@@ -64,7 +55,7 @@ module Avm
|
|
64
55
|
end
|
65
56
|
|
66
57
|
def files_banner
|
67
|
-
return unless
|
58
|
+
return unless parsed.files?
|
68
59
|
|
69
60
|
commit.files.each do |file|
|
70
61
|
infov " #{file.path}", file_value(file)
|
@@ -82,11 +73,11 @@ module Avm
|
|
82
73
|
end
|
83
74
|
|
84
75
|
def reference
|
85
|
-
|
76
|
+
parsed.ref
|
86
77
|
end
|
87
78
|
|
88
79
|
def git_uncached
|
89
|
-
::EacLauncher::Git::Base.new(
|
80
|
+
::EacLauncher::Git::Base.new(runner_context.call(:repository_path))
|
90
81
|
end
|
91
82
|
|
92
83
|
def commit_uncached
|
@@ -103,7 +94,7 @@ module Avm
|
|
103
94
|
end
|
104
95
|
|
105
96
|
def show_size?
|
106
|
-
|
97
|
+
parsed.size?
|
107
98
|
end
|
108
99
|
end
|
109
100
|
end
|
data/lib/avm/tools/version.rb
CHANGED
@@ -8,7 +8,8 @@ module EacCli
|
|
8
8
|
DEFAULT_REQUIRED = false
|
9
9
|
|
10
10
|
enable_listable
|
11
|
-
|
11
|
+
enable_abstract_methods :build_value, :default_value
|
12
|
+
lists.add_symbol :option, :optional, :usage, :repeat, :required
|
12
13
|
attr_reader :short, :long, :description, :options
|
13
14
|
|
14
15
|
def initialize(short, long, description, options = {})
|
@@ -23,6 +24,10 @@ module EacCli
|
|
23
24
|
long.to_s.variableize.to_sym
|
24
25
|
end
|
25
26
|
|
27
|
+
def repeat?
|
28
|
+
options[OPTION_REPEAT]
|
29
|
+
end
|
30
|
+
|
26
31
|
def required?
|
27
32
|
return true if options.key?(:required) && options.fetch(:required)
|
28
33
|
return false if options.key?(:optional) && options.fetch(:optional)
|
@@ -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
|
@@ -24,11 +24,7 @@ module EacCli
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def collect(option, value)
|
27
|
-
|
28
|
-
data[option] << value
|
29
|
-
else
|
30
|
-
data[option] = value
|
31
|
-
end
|
27
|
+
data[option] = option.build_value(value, data[option])
|
32
28
|
end
|
33
29
|
|
34
30
|
def supplied?(option)
|
@@ -42,18 +38,8 @@ module EacCli
|
|
42
38
|
end
|
43
39
|
|
44
40
|
def default_values
|
45
|
-
definition.options.each { |option| data[option] =
|
46
|
-
definition.positional.each
|
47
|
-
data[positional] = positional_default_value(positional)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def option_default_value(option)
|
52
|
-
option.argument? ? nil : false
|
53
|
-
end
|
54
|
-
|
55
|
-
def positional_default_value(positional)
|
56
|
-
positional.repeat? ? [] : nil
|
41
|
+
definition.options.each { |option| data[option] = option.default_value }
|
42
|
+
definition.positional.each { |positional| data[positional] = positional.default_value }
|
57
43
|
end
|
58
44
|
end
|
59
45
|
end
|
@@ -12,6 +12,8 @@ RSpec.describe ::EacCli::Runner do
|
|
12
12
|
runner_definition do
|
13
13
|
arg_opt '-o', '--opt1', 'A arg option.'
|
14
14
|
bool_opt '-p', '--opt2', 'A boolean option'
|
15
|
+
arg_opt '-q', '--opt4', 'A repeatable argument option.', repeat: true
|
16
|
+
bool_opt '-r', '--opt5', 'A repeatable boolean option', repeat: true
|
15
17
|
pos_arg :pos1
|
16
18
|
pos_arg :pos2, repeat: true, optional: true
|
17
19
|
alt do
|
@@ -29,7 +31,7 @@ RSpec.describe ::EacCli::Runner do
|
|
29
31
|
context 'when all args are supplied' do
|
30
32
|
let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
|
31
33
|
let(:parsed_expected) do
|
32
|
-
{ opt1: 'aaa', opt2: true, opt3: false, pos1: 'bbb',
|
34
|
+
{ opt1: 'aaa', opt2: true, opt3: false, opt4: [], opt5: 0, pos1: 'bbb',
|
33
35
|
pos2: %w[ccc ddd] }
|
34
36
|
end
|
35
37
|
|
@@ -63,7 +65,10 @@ RSpec.describe ::EacCli::Runner do
|
|
63
65
|
|
64
66
|
context 'when only required args are supplied' do
|
65
67
|
let(:argv) { %w[bbb] }
|
66
|
-
let(:parsed_expected)
|
68
|
+
let(:parsed_expected) do
|
69
|
+
{ opt1: nil, opt2: false, opt3: false, opt4: [], opt5: 0, pos1: 'bbb',
|
70
|
+
pos2: [] }
|
71
|
+
end
|
67
72
|
|
68
73
|
it { expect(parsed_actual).to eq(parsed_expected) }
|
69
74
|
it { expect(instance.parsed.opt1).to be_nil }
|
@@ -82,12 +87,25 @@ RSpec.describe ::EacCli::Runner do
|
|
82
87
|
|
83
88
|
context 'when alternative args are supplied' do
|
84
89
|
let(:argv) { %w[--opt3] }
|
85
|
-
let(:parsed_expected)
|
90
|
+
let(:parsed_expected) do
|
91
|
+
{ opt1: nil, opt2: false, opt3: true, opt4: [], opt5: 0, pos1: nil,
|
92
|
+
pos2: [] }
|
93
|
+
end
|
86
94
|
|
87
95
|
it { expect(parsed_actual).to eq(parsed_expected) }
|
88
96
|
it { expect(instance.parsed.opt3?).to eq(true) }
|
89
97
|
end
|
90
98
|
|
99
|
+
context 'when repeated options are supplied' do
|
100
|
+
let(:argv) { %w[--opt5 -rrr --opt4=A -q B --opt4 C AAA] }
|
101
|
+
let(:parsed_expected) do
|
102
|
+
{ opt1: nil, opt2: false, opt3: false, opt4: %w[A B C], opt5: 4, pos1: 'AAA',
|
103
|
+
pos2: [] }
|
104
|
+
end
|
105
|
+
|
106
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
107
|
+
end
|
108
|
+
|
91
109
|
context 'when extra args are not supplied' do
|
92
110
|
let(:runner_class) do
|
93
111
|
the_module = described_class
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.92.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -400,6 +400,13 @@ files:
|
|
400
400
|
- lib/avm/files/rotate.rb
|
401
401
|
- lib/avm/fs_cache.rb
|
402
402
|
- lib/avm/git.rb
|
403
|
+
- lib/avm/git/auto_commit/commit_info.rb
|
404
|
+
- lib/avm/git/auto_commit/rules.rb
|
405
|
+
- lib/avm/git/auto_commit/rules/base.rb
|
406
|
+
- lib/avm/git/auto_commit/rules/last.rb
|
407
|
+
- lib/avm/git/auto_commit/rules/manual.rb
|
408
|
+
- lib/avm/git/auto_commit/rules/nth.rb
|
409
|
+
- lib/avm/git/auto_commit/rules/unique.rb
|
403
410
|
- lib/avm/git/auto_commit_path.rb
|
404
411
|
- lib/avm/git/auto_commit_path/ruby.rb
|
405
412
|
- lib/avm/git/commit.rb
|