eac_cli 0.37.0 → 0.38.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/eac_cli/config.rb +0 -4
- data/lib/eac_cli/core_ext.rb +1 -1
- data/lib/eac_cli/definition/alternative.rb +24 -3
- data/lib/eac_cli/definition.rb +1 -1
- data/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +1 -1
- data/lib/eac_cli/parser/alternative/any_options.rb +19 -0
- data/lib/eac_cli/parser/alternative/long_options.rb +1 -1
- data/lib/eac_cli/parser/alternative/short_options.rb +1 -3
- data/lib/eac_cli/parser/alternative.rb +0 -9
- data/lib/eac_cli/parser.rb +1 -1
- data/lib/eac_cli/patches/object.rb +1 -1
- data/lib/eac_cli/patches.rb +1 -1
- data/lib/eac_cli/runner/class_runner.rb +1 -1
- data/lib/eac_cli/runner/context_responders/set.rb +2 -2
- data/lib/eac_cli/runner/exit.rb +2 -1
- data/lib/eac_cli/runner/instance_methods.rb +1 -1
- data/lib/eac_cli/runner_with/help/builder/alternative.rb +1 -1
- data/lib/eac_cli/runner_with/help/builder.rb +2 -2
- data/lib/eac_cli/runner_with/help.rb +1 -0
- data/lib/eac_cli/runner_with/subcommands.rb +1 -1
- data/lib/eac_cli/runner_with_set.rb +1 -1
- data/lib/eac_cli/speaker/list.rb +4 -4
- data/lib/eac_cli/speaker/options.rb +3 -3
- data/lib/eac_cli/speaker.rb +2 -1
- data/lib/eac_cli/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e016c3cb10caefe2fcc4f81d73dbdf76cff97a0e11ecb49f4b8378be238b7a
|
4
|
+
data.tar.gz: 676cf803931311818d97ea9a5421e360e16a36495e93a2cf90a938afdb526562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9902444b9eb020f42bf0b33c2c7afe5c8dae6651ad7ae2f6a0b57a563424715eed55058ca48f4b50d572a1284a62d0c4e0246ecbb0b15f907c10b12254a6f7b3
|
7
|
+
data.tar.gz: d62d638adea120b7dd203cafff53646a40ef011659bb952216e130d49988d06ceb151f85caf5832301092448c95ef46ffe82223ba550f6a9c6bb2b298bf21e3e
|
data/Gemfile
CHANGED
@@ -4,5 +4,5 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
local_gemfile =
|
8
|
-
eval_gemfile local_gemfile if
|
7
|
+
local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
|
8
|
+
eval_gemfile local_gemfile if File.exist?(local_gemfile)
|
data/lib/eac_cli/config.rb
CHANGED
data/lib/eac_cli/core_ext.rb
CHANGED
@@ -7,9 +7,30 @@ require 'eac_cli/definition/positional_argument'
|
|
7
7
|
module EacCli
|
8
8
|
class Definition
|
9
9
|
class Alternative
|
10
|
+
ANY_OPTION_DESCRIPTION = 'ANY_OPTION'
|
11
|
+
ANY_OPTION_LONG = '__'
|
12
|
+
ANY_OPTION_SHORT = '_'
|
10
13
|
SUBCOMMAND_NAME_ARG = :subcommand
|
11
14
|
SUBCOMMAND_ARGS_ARG = :subcommand_args
|
12
15
|
|
16
|
+
# @return [Boolean]
|
17
|
+
def any_opt
|
18
|
+
@any_opt = true
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
def any_option?
|
23
|
+
@any_opt ? true : false
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [EacCli::Definition::BooleanOption]
|
27
|
+
def any_options_option
|
28
|
+
@any_options_option ||= ::EacCli::Definition::BooleanOption.new(
|
29
|
+
ANY_OPTION_SHORT, ANY_OPTION_LONG, ANY_OPTION_DESCRIPTION,
|
30
|
+
optional: true, repeat: true, usage: false
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
13
34
|
def arg_opt(*args)
|
14
35
|
options_set << ::EacCli::Definition::ArgumentOption.from_args(args)
|
15
36
|
end
|
@@ -48,7 +69,7 @@ module EacCli
|
|
48
69
|
return 'there are subcommands' if subcommands?
|
49
70
|
return 'last argument repeats' if last.repeat?
|
50
71
|
return 'new argument is required and last is optional' if
|
51
|
-
|
72
|
+
last.optional? && new_pos_arg.if_present(&:required?)
|
52
73
|
|
53
74
|
nil
|
54
75
|
end
|
@@ -67,8 +88,8 @@ module EacCli
|
|
67
88
|
|
68
89
|
def check_positional_blocked(new_pos_arg)
|
69
90
|
positional_arguments_blocked_reason(new_pos_arg).if_present do |v|
|
70
|
-
raise ::EacCli::Definition::Error, "Positional arguments are blocked: #{v}" \
|
71
|
-
|
91
|
+
raise ::EacCli::Definition::Error, "Positional arguments are blocked: #{v} " \
|
92
|
+
"(New argument: #{new_pos_arg})"
|
72
93
|
end
|
73
94
|
end
|
74
95
|
|
data/lib/eac_cli/definition.rb
CHANGED
@@ -17,7 +17,7 @@ module EacCli
|
|
17
17
|
def banner
|
18
18
|
infom 'Do you wanna to store passwords?'
|
19
19
|
infom 'Warning: the passwords will be store in clear text in ' \
|
20
|
-
|
20
|
+
"\"#{console_configs.configs.storage_path}\""
|
21
21
|
infom 'Enter "yes" or "no"'
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Parser
|
7
|
+
class Alternative
|
8
|
+
module AnyOptions
|
9
|
+
delegate :any_option?, to: :alternative
|
10
|
+
|
11
|
+
# @return [EacCli::Definition::BooleanOption] if #any_option? is true.
|
12
|
+
# @raise [EacCli::Parser::Error] if #any_option? is false.
|
13
|
+
def any_option_collect_option
|
14
|
+
any_option? ? alternative.any_options_option : raise_argv_current_invalid_option
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -33,9 +33,7 @@ module EacCli
|
|
33
33
|
# @return [EacCli::Definition::BaseOption] The option collected.
|
34
34
|
def short_option_collect_char(char)
|
35
35
|
option = find_short_option(char)
|
36
|
-
|
37
|
-
|
38
|
-
option_collect_option(option)
|
36
|
+
option ? option_collect_option(option) : any_option_collect_option
|
39
37
|
end
|
40
38
|
|
41
39
|
def short_without_prefix(short)
|
@@ -62,15 +62,6 @@ module EacCli
|
|
62
62
|
argv_enum.next
|
63
63
|
end
|
64
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
65
|
def raise_error(message)
|
75
66
|
raise ::EacCli::Parser::Error.new(alternative, argv, message)
|
76
67
|
end
|
data/lib/eac_cli/parser.rb
CHANGED
@@ -12,7 +12,7 @@ module EacCli
|
|
12
12
|
|
13
13
|
def parsed_uncached
|
14
14
|
raise 'Definition has no alternatives' if alternatives.empty?
|
15
|
-
raise first_error unless alternatives.
|
15
|
+
raise first_error unless alternatives.any?(&:success?)
|
16
16
|
|
17
17
|
alternatives_parsed(true).merge(alternatives_parsed(false))
|
18
18
|
end
|
data/lib/eac_cli/patches.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) # rubocop:disable Rails/Exit
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -18,9 +18,9 @@ module EacCli
|
|
18
18
|
responders_instances.any?(&:callable?)
|
19
19
|
end
|
20
20
|
|
21
|
-
def call(
|
21
|
+
def call(...)
|
22
22
|
caller = responder_to_call
|
23
|
-
return caller.call(
|
23
|
+
return caller.call(...) if caller
|
24
24
|
|
25
25
|
raise ::NameError, "No method \"#{method_name}\" found in #{runner} or in its ancestors"
|
26
26
|
end
|
data/lib/eac_cli/runner/exit.rb
CHANGED
@@ -26,7 +26,7 @@ module EacCli
|
|
26
26
|
|
27
27
|
def option_usage_full(option)
|
28
28
|
if option.long.present?
|
29
|
-
[option.short, option_long(option)].
|
29
|
+
[option.short, option_long(option)].compact_blank.join(word_separator)
|
30
30
|
else
|
31
31
|
option_short(option)
|
32
32
|
end
|
@@ -53,7 +53,7 @@ module EacCli
|
|
53
53
|
def option_definition(option)
|
54
54
|
[self.class.option_usage_full(option), option.description,
|
55
55
|
option.default_value? ? "[Default: \"#{option.default_value}\"]" : nil]
|
56
|
-
.
|
56
|
+
.compact_blank.join(OPTION_DESCRIPTION_SEPARATOR)
|
57
57
|
end
|
58
58
|
|
59
59
|
# @return [String]
|
@@ -105,7 +105,7 @@ module EacCli
|
|
105
105
|
raise(::EacCli::Parser::Error.new(
|
106
106
|
self.class.runner_definition, runner_context.argv,
|
107
107
|
"Subcommand \"#{subcommand_name}\" not found " \
|
108
|
-
|
108
|
+
"(Available: #{available_subcommands_to_s})"
|
109
109
|
))
|
110
110
|
end
|
111
111
|
|
data/lib/eac_cli/speaker/list.rb
CHANGED
@@ -17,11 +17,11 @@ module EacCli
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def hash_to_values(list)
|
20
|
-
list.map { |key, value| ::OpenStruct.new(key: key, label: key, value: value) }
|
20
|
+
list.map { |key, value| ::OpenStruct.new(key: key, label: key, value: value) } # rubocop:disable Style/OpenStructUse
|
21
21
|
end
|
22
22
|
|
23
23
|
def array_to_values(list)
|
24
|
-
list.map { |value| ::OpenStruct.new(key: value, label: value, value: value) }
|
24
|
+
list.map { |value| ::OpenStruct.new(key: value, label: value, value: value) } # rubocop:disable Style/OpenStructUse
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ module EacCli
|
|
29
29
|
|
30
30
|
def initialize(values)
|
31
31
|
@values = values.map do |v|
|
32
|
-
::OpenStruct.new(key: to_key(v.key), label: to_label(v.label), value: v.value)
|
32
|
+
::OpenStruct.new(key: to_key(v.key), label: to_label(v.label), value: v.value) # rubocop:disable Style/OpenStructUse
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -51,7 +51,7 @@ module EacCli
|
|
51
51
|
|
52
52
|
def build_value(value)
|
53
53
|
key = to_key(value)
|
54
|
-
values.each do |v|
|
54
|
+
values.each do |v|
|
55
55
|
return v.value if v.key == key
|
56
56
|
end
|
57
57
|
raise "Value not found: \"#{value}\" (#{values})"
|
@@ -11,15 +11,15 @@ module EacCli
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def err_out
|
14
|
-
option(OPTION_ERR_OUT,
|
14
|
+
option(OPTION_ERR_OUT, $stderr)
|
15
15
|
end
|
16
16
|
|
17
17
|
def out_out
|
18
|
-
option(OPTION_OUT_OUT,
|
18
|
+
option(OPTION_OUT_OUT, $stdout)
|
19
19
|
end
|
20
20
|
|
21
21
|
def in_in
|
22
|
-
option(OPTION_IN_IN,
|
22
|
+
option(OPTION_IN_IN, $stdin)
|
23
23
|
end
|
24
24
|
|
25
25
|
def err_line_prefix
|
data/lib/eac_cli/speaker.rb
CHANGED
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.
|
4
|
+
version: 0.38.0
|
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-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
version: '0.119'
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.119.
|
56
|
+
version: 0.119.2
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,21 +63,21 @@ dependencies:
|
|
63
63
|
version: '0.119'
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.119.
|
66
|
+
version: 0.119.2
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: eac_ruby_gem_support
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.
|
73
|
+
version: 0.8.1
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
80
|
+
version: 0.8.1
|
81
81
|
description:
|
82
82
|
email:
|
83
83
|
executables: []
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/eac_cli/old_configs/store_passwords_entry_reader.rb
|
110
110
|
- lib/eac_cli/parser.rb
|
111
111
|
- lib/eac_cli/parser/alternative.rb
|
112
|
+
- lib/eac_cli/parser/alternative/any_options.rb
|
112
113
|
- lib/eac_cli/parser/alternative/argv.rb
|
113
114
|
- lib/eac_cli/parser/alternative/double_dash.rb
|
114
115
|
- lib/eac_cli/parser/alternative/long_options.rb
|
@@ -173,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
174
|
requirements:
|
174
175
|
- - ">="
|
175
176
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
177
|
+
version: 2.7.0
|
177
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
180
|
- - ">="
|