eac_cli 0.38.0 → 0.38.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_cli/config/entry.rb +2 -1
- data/lib/eac_cli/definition/alternative.rb +4 -4
- data/lib/eac_cli/definition/argument_option.rb +2 -2
- data/lib/eac_cli/definition/boolean_option.rb +3 -4
- data/lib/eac_cli/definition/{base_option → option}/initialize_args_parser.rb +1 -1
- data/lib/eac_cli/definition/option.rb +73 -0
- data/lib/eac_cli/definition/option_or_positional.rb +43 -0
- data/lib/eac_cli/definition/{positional_argument.rb → positional.rb} +14 -22
- data/lib/eac_cli/definition.rb +17 -3
- data/lib/eac_cli/parser/alternative/argv.rb +2 -0
- data/lib/eac_cli/parser/alternative/short_options.rb +10 -1
- data/lib/eac_cli/parser/alternative.rb +20 -0
- data/lib/eac_cli/parser/collector.rb +10 -1
- data/lib/eac_cli/rspec.rb +1 -1
- data/lib/eac_cli/runner/class_runner.rb +1 -1
- data/lib/eac_cli/version.rb +1 -1
- metadata +14 -8
- data/lib/eac_cli/definition/base_option.rb +0 -68
- data/lib/eac_cli/definition/default_value.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a58c5ccac3080dd986b2727ce365a7979a801f059016faa0f7fe8dd8b86e1d3
|
4
|
+
data.tar.gz: 06cb591e776e862bfcbe048fb524f05a8bd06b3e85a86a14c28df40654355eba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebf30f86ad003589e75880af90d75058a55c9e76ed386f0a1972c175ed22c2ea8c135c765ff2cf1d7476591126eac66ea680b6f38c96a95a800069a140060fd
|
7
|
+
data.tar.gz: 1d2ea1f751023f5a11e2ef8465bab272429e29088e27123830fae2cb041d7ce4524c931c08a2088597664edc638bf6eb775c7a8e2b6ede1af05e09fe02bc7d7f
|
data/lib/eac_cli/config/entry.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_cli/definition/argument_option'
|
4
4
|
require 'eac_cli/definition/boolean_option'
|
5
|
-
require 'eac_cli/definition/
|
5
|
+
require 'eac_cli/definition/positional'
|
6
6
|
|
7
7
|
module EacCli
|
8
8
|
class Definition
|
@@ -54,7 +54,7 @@ module EacCli
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def pos_arg(name, arg_options = {})
|
57
|
-
new_pos_arg = ::EacCli::Definition::
|
57
|
+
new_pos_arg = ::EacCli::Definition::Positional.new(name, arg_options)
|
58
58
|
check_positional_blocked(new_pos_arg)
|
59
59
|
pos_set << new_pos_arg
|
60
60
|
end
|
@@ -76,8 +76,8 @@ module EacCli
|
|
76
76
|
|
77
77
|
def subcommands
|
78
78
|
pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
|
79
|
-
pos_set << ::EacCli::Definition::
|
80
|
-
|
79
|
+
pos_set << ::EacCli::Definition::Positional.new(SUBCOMMAND_ARGS_ARG,
|
80
|
+
optional: true, repeat: true)
|
81
81
|
end
|
82
82
|
|
83
83
|
def subcommands?
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_cli/definition/
|
3
|
+
require 'eac_cli/definition/option'
|
4
4
|
|
5
5
|
module EacCli
|
6
6
|
class Definition
|
7
|
-
class ArgumentOption < ::EacCli::Definition::
|
7
|
+
class ArgumentOption < ::EacCli::Definition::Option
|
8
8
|
def argument?
|
9
9
|
true
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_cli/definition/
|
3
|
+
require 'eac_cli/definition/option'
|
4
4
|
|
5
5
|
module EacCli
|
6
6
|
class Definition
|
7
|
-
class BooleanOption < ::EacCli::Definition::
|
7
|
+
class BooleanOption < ::EacCli::Definition::Option
|
8
8
|
def argument?
|
9
9
|
false
|
10
10
|
end
|
@@ -16,8 +16,7 @@ module EacCli
|
|
16
16
|
def default_value
|
17
17
|
return super unless default_value?
|
18
18
|
|
19
|
-
raise(
|
20
|
-
"Unallowed default value for boolean options (Option: #{self})")
|
19
|
+
raise("Unallowed default value for boolean options (Option: #{self})")
|
21
20
|
end
|
22
21
|
|
23
22
|
def default_default_value
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/definition/option_or_positional'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
class Definition
|
8
|
+
# @abstract
|
9
|
+
class Option < ::EacCli::Definition::OptionOrPositional
|
10
|
+
require_sub __FILE__
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# @param args [Enumerable<String>]
|
14
|
+
# @return [EacCli::Definition::Option]
|
15
|
+
def from_args(args)
|
16
|
+
p = ::EacCli::Definition::Option::InitializeArgsParser.new(args)
|
17
|
+
new(p.short, p.long, p.description, p.options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
DEFAULT_REQUIRED = false
|
22
|
+
|
23
|
+
enable_abstract_methods
|
24
|
+
lists.add_symbol :option, *OPTION_LIST, :default, :usage
|
25
|
+
|
26
|
+
# @!method initialize(short, long, description, options = {})
|
27
|
+
# @param short [String]
|
28
|
+
# @param long [String]
|
29
|
+
# @param description [String]
|
30
|
+
# @param options [Hash<Symbol, Object>]
|
31
|
+
# @raise [EacCli::Definition::Error]
|
32
|
+
common_constructor :short, :long, :description, :options, default: [{}] do
|
33
|
+
validate
|
34
|
+
self.options = ::EacCli::Definition::Option.lists.option.hash_keys_validate!(
|
35
|
+
options.symbolize_keys
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Object]
|
40
|
+
def default_value
|
41
|
+
default_value? ? options[OPTION_DEFAULT] : default_default_value
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Boolean]
|
45
|
+
def default_value?
|
46
|
+
options.key?(OPTION_DEFAULT)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Symbol]
|
50
|
+
# @raise [EacCli::Definition::Error] If no short or long option is provided.
|
51
|
+
def identifier
|
52
|
+
[long, short].each do |v|
|
53
|
+
v.to_s.if_present { |vv| return vv.variableize.to_sym }
|
54
|
+
end
|
55
|
+
|
56
|
+
raise('No short or long option to build identifier')
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Boolean]
|
60
|
+
def show_on_usage?
|
61
|
+
options[:usage]
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# @return [void]
|
67
|
+
# @raise [EacCli::Definition::Error]
|
68
|
+
def validate
|
69
|
+
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Definition
|
7
|
+
# @abstract
|
8
|
+
class OptionOrPositional
|
9
|
+
acts_as_abstract :build_value, :default_value, :identifier, :options
|
10
|
+
enable_listable
|
11
|
+
|
12
|
+
OPTION_LIST = %i[optional repeat required].freeze
|
13
|
+
|
14
|
+
# @return [Boolean]
|
15
|
+
def optional?
|
16
|
+
!required?
|
17
|
+
end
|
18
|
+
|
19
|
+
# @raise [EacCli::Definition::Error]
|
20
|
+
def raise(*args)
|
21
|
+
::Kernel.raise ::EacCli::Definition::Error, *args
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Boolean]
|
25
|
+
def repeat?
|
26
|
+
options[:repeat] ? true : false
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Boolean]
|
30
|
+
def required?
|
31
|
+
return true if options.key?(:required) && options.fetch(:required)
|
32
|
+
return false if options.key?(:optional) && options.fetch(:optional)
|
33
|
+
|
34
|
+
self.class.const_get('DEFAULT_REQUIRED')
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def to_s
|
39
|
+
"#{self.class.name.demodulize}[#{identifier}]"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,19 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_cli/definition/option_or_positional'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module EacCli
|
6
7
|
class Definition
|
7
|
-
class
|
8
|
+
class Positional < ::EacCli::Definition::OptionOrPositional
|
8
9
|
DEFAULT_REQUIRED = true
|
9
10
|
DEFAULT_VISIBLE = true
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
lists.add_symbol :option, *OPTION_LIST, :subcommand, :visible
|
13
|
+
|
14
|
+
# @!method initialize(name, options = {})
|
15
|
+
# @param name [String]
|
16
|
+
# @param options [Hash<Symbol, Object>]
|
13
17
|
common_constructor :name, :options, default: [{}] do
|
14
18
|
options.assert_valid_keys(self.class.lists.option.values)
|
15
19
|
end
|
16
20
|
|
21
|
+
# @param new_value [Array, Object]
|
22
|
+
# @param previous_value [Array, Object]
|
23
|
+
# @return [Array]
|
17
24
|
def build_value(new_value, previous_value)
|
18
25
|
if previous_value.is_a?(::Array)
|
19
26
|
previous_value + [new_value]
|
@@ -22,37 +29,22 @@ module EacCli
|
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
32
|
+
# @return [Object]
|
25
33
|
def default_value
|
26
34
|
repeat? ? [] : nil
|
27
35
|
end
|
28
36
|
|
37
|
+
# @return [Symbol]
|
29
38
|
def identifier
|
30
39
|
name.to_s.variableize.to_sym
|
31
40
|
end
|
32
41
|
|
33
|
-
|
34
|
-
!required?
|
35
|
-
end
|
36
|
-
|
37
|
-
def repeat?
|
38
|
-
options[OPTION_REPEAT]
|
39
|
-
end
|
40
|
-
|
41
|
-
def required?
|
42
|
-
return true if options.key?(OPTION_REQUIRED) && options.fetch(OPTION_REQUIRED)
|
43
|
-
return false if options.key?(OPTION_OPTIONAL) && options.fetch(OPTION_OPTIONAL)
|
44
|
-
|
45
|
-
DEFAULT_REQUIRED
|
46
|
-
end
|
47
|
-
|
42
|
+
# @return [Boolean]
|
48
43
|
def subcommand?
|
49
44
|
options[OPTION_SUBCOMMAND]
|
50
45
|
end
|
51
46
|
|
52
|
-
|
53
|
-
"#{self.class.name.demodulize}[#{identifier}]"
|
54
|
-
end
|
55
|
-
|
47
|
+
# @return [Boolean]
|
56
48
|
def visible?
|
57
49
|
options.key?(OPTION_VISIBLE) ? options.fetch(OPTION_VISIBLE) : DEFAULT_VISIBLE
|
58
50
|
end
|
data/lib/eac_cli/definition.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_cli/definition/argument_option'
|
4
4
|
require 'eac_cli/definition/boolean_option'
|
5
|
-
require 'eac_cli/definition/
|
5
|
+
require 'eac_cli/definition/positional'
|
6
6
|
require 'eac_ruby_utils/core_ext'
|
7
7
|
|
8
8
|
module EacCli
|
@@ -13,6 +13,7 @@ module EacCli
|
|
13
13
|
SUBCOMMAND_NAME_ARG = 'subcommand'
|
14
14
|
SUBCOMMAND_ARGS_ARG = 'subcommand_args'
|
15
15
|
|
16
|
+
# @return [String, nil]
|
16
17
|
attr_accessor :description
|
17
18
|
|
18
19
|
def initialize
|
@@ -20,25 +21,35 @@ module EacCli
|
|
20
21
|
alternatives_set[MAIN_ALTERNATIVE_KEY] = main_alternative
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
# @return [EacCli::Definition::Alternative]
|
25
|
+
def alt(key = nil, &block)
|
26
|
+
key ||= new_alternative_key
|
27
|
+
raise(::EacCli::Definition::Error, "A alternative with key=\"#{key}\" already exists") if
|
28
|
+
key.present? && alternatives_set.key?(key)
|
29
|
+
|
24
30
|
r = ::EacCli::Definition::Alternative.new
|
25
31
|
r.instance_eval(&block)
|
26
|
-
alternatives_set[
|
32
|
+
alternatives_set[key] = r
|
27
33
|
r
|
28
34
|
end
|
29
35
|
|
36
|
+
# @return [Enumerable<EacCli::Definition::Alternative>]
|
30
37
|
def alternatives
|
31
38
|
alternatives_set.values
|
32
39
|
end
|
33
40
|
|
41
|
+
# @return [EacCli::Definition::Alternative]
|
42
|
+
# @raise [KeyError] If there is not a alternative with provided key.
|
34
43
|
def alternative(key)
|
35
44
|
alternatives_set.fetch(key)
|
36
45
|
end
|
37
46
|
|
47
|
+
# Same as {#description=}.
|
38
48
|
def desc(description)
|
39
49
|
self.description = description
|
40
50
|
end
|
41
51
|
|
52
|
+
# @return [EacCli::Definition::Alternative]
|
42
53
|
def main_alternative
|
43
54
|
@main_alternative ||= begin
|
44
55
|
r = ::EacCli::Definition::Alternative.new
|
@@ -47,10 +58,13 @@ module EacCli
|
|
47
58
|
end
|
48
59
|
end
|
49
60
|
|
61
|
+
# Same as {#options_argument=}.
|
62
|
+
# @param options_argument [Boolean]
|
50
63
|
def options_arg(options_argument)
|
51
64
|
self.options_argument = options_argument
|
52
65
|
end
|
53
66
|
|
67
|
+
# @return [Boolean]
|
54
68
|
def options_argument
|
55
69
|
main_alternative.options_argument?
|
56
70
|
end
|
@@ -5,23 +5,29 @@ module EacCli
|
|
5
5
|
class Alternative
|
6
6
|
module ShortOptions
|
7
7
|
SHORT_OPTION_PREFIX = '-'
|
8
|
+
SHORT_OPTION_CHAR_PATTERN = /\A[0-9a-zA-Z]\z/.freeze
|
8
9
|
|
9
10
|
private
|
10
11
|
|
12
|
+
# @return [Boolean]
|
11
13
|
def argv_current_short_option?
|
12
14
|
phase == PHASE_ANY && argv_enum.peek.start_with?(SHORT_OPTION_PREFIX) &&
|
13
15
|
!argv_current_long_option?
|
14
16
|
end
|
15
17
|
|
18
|
+
# @para char [String]
|
19
|
+
# @return [EacCli::Definition::Option, nil]
|
16
20
|
def find_short_option(char)
|
17
21
|
alternative.options.find do |option|
|
18
22
|
short_without_prefix(option.short).if_present(false) { |v| v == char }
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [void]
|
22
27
|
def short_option_collect_argv_value
|
23
28
|
last_option = nil
|
24
29
|
short_without_prefix(argv_enum.peek).each_char do |char|
|
30
|
+
raise_error "Invalid option: \"#{char}\"" unless SHORT_OPTION_CHAR_PATTERN.match?(char)
|
25
31
|
raise_error "Option \"#{last_option}\" requires a argument not provided" if
|
26
32
|
last_option.present?
|
27
33
|
|
@@ -30,12 +36,15 @@ module EacCli
|
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
|
-
# @
|
39
|
+
# @param char [String]
|
40
|
+
# @return [EacCli::Definition::Option] The option collected.
|
34
41
|
def short_option_collect_char(char)
|
35
42
|
option = find_short_option(char)
|
36
43
|
option ? option_collect_option(option) : any_option_collect_option
|
37
44
|
end
|
38
45
|
|
46
|
+
# @param short [String]
|
47
|
+
# @return [String]
|
39
48
|
def short_without_prefix(short)
|
40
49
|
short.to_s.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
|
41
50
|
end
|
@@ -10,30 +10,40 @@ module EacCli
|
|
10
10
|
require_sub __FILE__, include_modules: true
|
11
11
|
enable_listable
|
12
12
|
lists.add_symbol :phase, :any, :option_argument, :positional
|
13
|
+
|
14
|
+
# @return [EacCli::Parser::Error, nil]
|
13
15
|
attr_reader :error
|
14
16
|
|
17
|
+
# @!method initialize(alternative, argv)
|
18
|
+
# @param alternative [EacCli::Definition::Alternative]
|
19
|
+
# @param argv [Array<String>]
|
15
20
|
common_constructor :alternative, :argv do
|
16
21
|
alternative.assert_argument(::EacCli::Definition::Alternative, :alternative)
|
17
22
|
self.phase = PHASE_ANY
|
18
23
|
collect
|
19
24
|
end
|
20
25
|
|
26
|
+
# @return [Boolean]
|
21
27
|
def error?
|
22
28
|
error.present?
|
23
29
|
end
|
24
30
|
|
31
|
+
# @return [Boolean]
|
25
32
|
def success?
|
26
33
|
!error?
|
27
34
|
end
|
28
35
|
|
36
|
+
# @return [EacRubyUtils::Struct]
|
29
37
|
def parsed
|
30
38
|
@parsed ||= collector.to_data.freeze
|
31
39
|
end
|
32
40
|
|
33
41
|
private
|
34
42
|
|
43
|
+
# @return [Symbol]
|
35
44
|
attr_accessor :phase
|
36
45
|
|
46
|
+
# @return [void]
|
37
47
|
def any_collect_argv_value
|
38
48
|
%w[double_dash long_option short_option].each do |arg_type|
|
39
49
|
return send("#{arg_type}_collect_argv_value") if send("argv_current_#{arg_type}?")
|
@@ -42,10 +52,12 @@ module EacCli
|
|
42
52
|
positional_collect_argv_value
|
43
53
|
end
|
44
54
|
|
55
|
+
# @return [EacCli::Parser::Collector]
|
45
56
|
def collector
|
46
57
|
@collector ||= ::EacCli::Parser::Collector.new(alternative)
|
47
58
|
end
|
48
59
|
|
60
|
+
# @return [void]
|
49
61
|
def collect
|
50
62
|
loop do
|
51
63
|
break unless argv_pending?
|
@@ -57,21 +69,29 @@ module EacCli
|
|
57
69
|
@error = e
|
58
70
|
end
|
59
71
|
|
72
|
+
# @return [void]
|
60
73
|
def collect_argv_value
|
61
74
|
send("#{phase}_collect_argv_value")
|
62
75
|
argv_enum.next
|
63
76
|
end
|
64
77
|
|
78
|
+
# @param message [String]
|
79
|
+
# @raise [EacCli::Parser::Error] Always.
|
65
80
|
def raise_error(message)
|
66
81
|
raise ::EacCli::Parser::Error.new(alternative, argv, message)
|
67
82
|
end
|
68
83
|
|
84
|
+
# @return [void]
|
85
|
+
# @raise [EacCli::Parser::Error] If options where not properly supplied.
|
69
86
|
def validate
|
70
87
|
(alternative.options + alternative.positional).each do |option|
|
71
88
|
validate_option(option)
|
72
89
|
end
|
73
90
|
end
|
74
91
|
|
92
|
+
# @param option [EacCli::Definition::Option, EacCli::Definition::Positional]
|
93
|
+
# @return [void]
|
94
|
+
# @raise [EacCli::Parser::Error] If option was not properly supplied.
|
75
95
|
def validate_option(option)
|
76
96
|
return unless option.required?
|
77
97
|
return if collector.supplied?(option)
|
@@ -14,29 +14,38 @@ module EacCli
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# @!method initialize(definition)
|
18
|
+
# @param definition [EacCli::Definition]
|
17
19
|
common_constructor :definition do
|
18
20
|
default_values
|
19
21
|
end
|
20
22
|
|
21
|
-
# @return [
|
23
|
+
# @return [EacRubyUtils::Struct]
|
22
24
|
def to_data
|
23
25
|
::EacRubyUtils::Struct.new(data.transform_keys(&:identifier))
|
24
26
|
end
|
25
27
|
|
28
|
+
# @param option [EacCli::Definition::Option]
|
29
|
+
# @param value [String]
|
30
|
+
# @return [void]
|
26
31
|
def collect(option, value)
|
27
32
|
data[option] = option.build_value(value, data[option])
|
28
33
|
end
|
29
34
|
|
35
|
+
# @param option [EacCli::Definition::Option]
|
36
|
+
# @return [Boolean]
|
30
37
|
def supplied?(option)
|
31
38
|
data[option].present?
|
32
39
|
end
|
33
40
|
|
34
41
|
private
|
35
42
|
|
43
|
+
# @return [Hash]
|
36
44
|
def data
|
37
45
|
@data ||= {}
|
38
46
|
end
|
39
47
|
|
48
|
+
# @return [void]
|
40
49
|
def default_values
|
41
50
|
definition.options.each { |option| data[option] = option.default_value }
|
42
51
|
definition.positional.each { |positional| data[positional] = positional.default_value }
|
data/lib/eac_cli/rspec.rb
CHANGED
@@ -29,7 +29,7 @@ module EacCli
|
|
29
29
|
|
30
30
|
def run_parser_error(runner_instance, error)
|
31
31
|
$stderr.write("#{runner_instance.program_name}: #{error}\n")
|
32
|
-
::Kernel.exit(PARSER_ERROR_EXIT_CODE)
|
32
|
+
::Kernel.exit(PARSER_ERROR_EXIT_CODE)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/eac_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.38.
|
4
|
+
version: 0.38.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -37,6 +37,9 @@ dependencies:
|
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.14'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.14.1
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,6 +47,9 @@ dependencies:
|
|
44
47
|
- - "~>"
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: '0.14'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.14.1
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: eac_ruby_utils
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,14 +76,14 @@ dependencies:
|
|
70
76
|
requirements:
|
71
77
|
- - "~>"
|
72
78
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.
|
79
|
+
version: '0.9'
|
74
80
|
type: :development
|
75
81
|
prerelease: false
|
76
82
|
version_requirements: !ruby/object:Gem::Requirement
|
77
83
|
requirements:
|
78
84
|
- - "~>"
|
79
85
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
86
|
+
version: '0.9'
|
81
87
|
description:
|
82
88
|
email:
|
83
89
|
executables: []
|
@@ -95,12 +101,12 @@ files:
|
|
95
101
|
- lib/eac_cli/definition.rb
|
96
102
|
- lib/eac_cli/definition/alternative.rb
|
97
103
|
- lib/eac_cli/definition/argument_option.rb
|
98
|
-
- lib/eac_cli/definition/base_option.rb
|
99
|
-
- lib/eac_cli/definition/base_option/initialize_args_parser.rb
|
100
104
|
- lib/eac_cli/definition/boolean_option.rb
|
101
|
-
- lib/eac_cli/definition/default_value.rb
|
102
105
|
- lib/eac_cli/definition/error.rb
|
103
|
-
- lib/eac_cli/definition/
|
106
|
+
- lib/eac_cli/definition/option.rb
|
107
|
+
- lib/eac_cli/definition/option/initialize_args_parser.rb
|
108
|
+
- lib/eac_cli/definition/option_or_positional.rb
|
109
|
+
- lib/eac_cli/definition/positional.rb
|
104
110
|
- lib/eac_cli/enum.rb
|
105
111
|
- lib/eac_cli/old_configs.rb
|
106
112
|
- lib/eac_cli/old_configs/entry_reader.rb
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_cli/definition/default_value'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module EacCli
|
7
|
-
class Definition
|
8
|
-
class BaseOption
|
9
|
-
require_sub __FILE__
|
10
|
-
include ::EacCli::Definition::DefaultValue
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def from_args(args)
|
14
|
-
p = ::EacCli::Definition::BaseOption::InitializeArgsParser.new(args)
|
15
|
-
new(p.short, p.long, p.description, p.options)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
DEFAULT_REQUIRED = false
|
20
|
-
|
21
|
-
enable_listable
|
22
|
-
enable_abstract_methods :build_value
|
23
|
-
lists.add_symbol :option, :default, :optional, :usage, :repeat, :required
|
24
|
-
common_constructor :short, :long, :description, :options, default: [{}] do
|
25
|
-
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
26
|
-
|
27
|
-
self.options = ::EacCli::Definition::BaseOption.lists.option.hash_keys_validate!(
|
28
|
-
options.symbolize_keys
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def default_value
|
33
|
-
default_value? ? options[OPTION_DEFAULT] : default_default_value
|
34
|
-
end
|
35
|
-
|
36
|
-
def default_value?
|
37
|
-
options.key?(OPTION_DEFAULT)
|
38
|
-
end
|
39
|
-
|
40
|
-
def identifier
|
41
|
-
[long, short].each do |v|
|
42
|
-
v.to_s.if_present { |vv| return vv.variableize.to_sym }
|
43
|
-
end
|
44
|
-
|
45
|
-
raise(::EacCli::Definition::Error, 'No short or long option to build identifier')
|
46
|
-
end
|
47
|
-
|
48
|
-
def repeat?
|
49
|
-
options[OPTION_REPEAT]
|
50
|
-
end
|
51
|
-
|
52
|
-
def required?
|
53
|
-
return true if options.key?(:required) && options.fetch(:required)
|
54
|
-
return false if options.key?(:optional) && options.fetch(:optional)
|
55
|
-
|
56
|
-
DEFAULT_REQUIRED
|
57
|
-
end
|
58
|
-
|
59
|
-
def to_s
|
60
|
-
"#{self.class.name.demodulize}[#{identifier}]"
|
61
|
-
end
|
62
|
-
|
63
|
-
def show_on_usage?
|
64
|
-
options[:usage]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacCli
|
6
|
-
class Definition
|
7
|
-
module DefaultValue
|
8
|
-
def default_value
|
9
|
-
default_value? ? options[OPTION_DEFAULT] : default_default_value
|
10
|
-
end
|
11
|
-
|
12
|
-
def default_value?
|
13
|
-
options.key?(OPTION_DEFAULT)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|