eac_cli 0.13.0 → 0.14.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ca942fefac703528e400de1a095cad1dd85d648895eabf7cfdf51ac430b34fe
|
|
4
|
+
data.tar.gz: 73f8e8c595e7669756b134d35576a1a3f873b67dfda1def674ea02d4a60173a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95cbcedfb77ca5d9fd3a3ffe2f818d9a8866d6774cc25bf3964f0a0fa1c81a3014afb6f3a26cb32393fd84fe76e56e159a5be22f0780e5d916b1d66f90a08961
|
|
7
|
+
data.tar.gz: 4a9cf2040a0cdae39543379f3da011931d11bbc22c15aca1a0c88838a592215d80c6fd413b034f66c991487d7f6a5b32eecc9b9d29530c787aba09c3f48c4daa
|
|
@@ -10,15 +10,12 @@ module EacCli
|
|
|
10
10
|
SUBCOMMAND_NAME_ARG = :subcommand
|
|
11
11
|
SUBCOMMAND_ARGS_ARG = :subcommand_args
|
|
12
12
|
|
|
13
|
-
def arg_opt(
|
|
14
|
-
options_set << ::EacCli::Definition::ArgumentOption.
|
|
15
|
-
short, long, description, option_options
|
|
16
|
-
)
|
|
13
|
+
def arg_opt(*args)
|
|
14
|
+
options_set << ::EacCli::Definition::ArgumentOption.from_args(args)
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
def bool_opt(
|
|
20
|
-
options_set << ::EacCli::Definition::BooleanOption.
|
|
21
|
-
option_options)
|
|
17
|
+
def bool_opt(*args)
|
|
18
|
+
options_set << ::EacCli::Definition::BooleanOption.from_args(args)
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
def options
|
|
@@ -5,19 +5,26 @@ require 'eac_ruby_utils/core_ext'
|
|
|
5
5
|
module EacCli
|
|
6
6
|
class Definition
|
|
7
7
|
class BaseOption
|
|
8
|
+
require_sub __FILE__
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
def from_args(args)
|
|
12
|
+
p = ::EacCli::Definition::BaseOption::InitializeArgsParser.new(args)
|
|
13
|
+
new(p.short, p.long, p.description, p.options)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
8
17
|
DEFAULT_REQUIRED = false
|
|
9
18
|
|
|
10
19
|
enable_listable
|
|
11
20
|
enable_abstract_methods :build_value, :default_value
|
|
12
21
|
lists.add_symbol :option, :optional, :usage, :repeat, :required
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@options = options.symbolize_keys
|
|
20
|
-
@options.assert_valid_keys(::EacCli::Definition::BaseOption.lists.option.values)
|
|
22
|
+
common_constructor :short, :long, :description, :options, default: [{}] do
|
|
23
|
+
raise 'Nor short neither long selector was set' if short.blank? && long.blank?
|
|
24
|
+
|
|
25
|
+
self.options = ::EacCli::Definition::BaseOption.lists.option.hash_keys_validate!(
|
|
26
|
+
options.symbolize_keys
|
|
27
|
+
)
|
|
21
28
|
end
|
|
22
29
|
|
|
23
30
|
def identifier
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacCli
|
|
4
|
+
class Definition
|
|
5
|
+
class BaseOption
|
|
6
|
+
class InitializeArgsParser
|
|
7
|
+
PROPERTIES = %i[short long description options].freeze
|
|
8
|
+
attr_reader(*PROPERTIES)
|
|
9
|
+
|
|
10
|
+
def initialize(args)
|
|
11
|
+
self.options = args.extract_options!.freeze
|
|
12
|
+
args.each { |arg| absorb_arg(arg) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
attr_writer(*PROPERTIES)
|
|
18
|
+
|
|
19
|
+
def absorb_arg(arg)
|
|
20
|
+
arg_ext = ArgumentParser.new(arg)
|
|
21
|
+
send("#{arg_ext.type}=", arg_ext.value)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class ArgumentParser
|
|
25
|
+
TYPES = %i[short long description].freeze
|
|
26
|
+
common_constructor :value
|
|
27
|
+
|
|
28
|
+
def type
|
|
29
|
+
TYPES.find { |type| send("#{type}?") } || raise("Unknown type for \"#{value}\"")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def short?
|
|
33
|
+
value.start_with?('-') && !long?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def long?
|
|
37
|
+
value.start_with?('--')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def description?
|
|
41
|
+
!short? || !long?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -19,10 +19,24 @@ module EacCli
|
|
|
19
19
|
b += '=<value>' if option.argument?
|
|
20
20
|
b
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
def option_short(option)
|
|
24
|
+
b = option.short
|
|
25
|
+
b += '=<value>' if option.argument?
|
|
26
|
+
b
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def option_usage_full(option)
|
|
30
|
+
if option.long.present?
|
|
31
|
+
[option.short, option_long(option)].reject(&:blank?).join(SEP)
|
|
32
|
+
else
|
|
33
|
+
option_short(option)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
22
36
|
end
|
|
23
37
|
|
|
24
38
|
def option_definition(option)
|
|
25
|
-
|
|
39
|
+
self.class.option_usage_full(option) + OPTION_DESC_SEP + option.description
|
|
26
40
|
end
|
|
27
41
|
|
|
28
42
|
def section(header, include_header = true)
|
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.14.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: 2021-02-
|
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: eac_ruby_utils
|
|
@@ -58,6 +58,7 @@ files:
|
|
|
58
58
|
- lib/eac_cli/definition/alternative.rb
|
|
59
59
|
- lib/eac_cli/definition/argument_option.rb
|
|
60
60
|
- lib/eac_cli/definition/base_option.rb
|
|
61
|
+
- lib/eac_cli/definition/base_option/initialize_args_parser.rb
|
|
61
62
|
- lib/eac_cli/definition/boolean_option.rb
|
|
62
63
|
- lib/eac_cli/definition/help_formatter.rb
|
|
63
64
|
- lib/eac_cli/definition/positional_argument.rb
|