eac_cli 0.38.0 → 0.39.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: c8e016c3cb10caefe2fcc4f81d73dbdf76cff97a0e11ecb49f4b8378be238b7a
4
- data.tar.gz: 676cf803931311818d97ea9a5421e360e16a36495e93a2cf90a938afdb526562
3
+ metadata.gz: 4eb32e4256c41224161c945741a0f3d2b3118c1cadaa1f3803d06a963c014f73
4
+ data.tar.gz: adbea33366cb3f15a78d034d9e6fe1e717ea04d1d7a5d00def1233eecc4ab10d
5
5
  SHA512:
6
- metadata.gz: 9902444b9eb020f42bf0b33c2c7afe5c8dae6651ad7ae2f6a0b57a563424715eed55058ca48f4b50d572a1284a62d0c4e0246ecbb0b15f907c10b12254a6f7b3
7
- data.tar.gz: d62d638adea120b7dd203cafff53646a40ef011659bb952216e130d49988d06ceb151f85caf5832301092448c95ef46ffe82223ba550f6a9c6bb2b298bf21e3e
6
+ metadata.gz: 3c45d3e0176a8f85691d7d64d54a4cfe7febeb25e982af587824afe84ce368515983dbb3a308aec46c0603340c2afeab6fccce914faaa4d2fc3fdce38177963c
7
+ data.tar.gz: 864ed661fddcae5c1e7ee6f1b1b81b6d20d98d184d6c24cecd8a7641b0afa9a28aa39215764b43a3dd5d7316ad7dcae02cdfcdd42fb6af47a8aae67183e62773
@@ -22,8 +22,9 @@ module EacCli
22
22
  root_node
23
23
  end
24
24
 
25
+ # @return [Object, nil]
25
26
  def value
26
- value!
27
+ sub_entry.found? ? sub_value_to_return : nil
27
28
  end
28
29
 
29
30
  def value!
@@ -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/positional_argument'
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::PositionalArgument.new(name, arg_options)
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::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
80
- optional: true, repeat: true)
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/base_option'
3
+ require 'eac_cli/definition/option'
4
4
 
5
5
  module EacCli
6
6
  class Definition
7
- class ArgumentOption < ::EacCli::Definition::BaseOption
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/base_option'
3
+ require 'eac_cli/definition/option'
4
4
 
5
5
  module EacCli
6
6
  class Definition
7
- class BooleanOption < ::EacCli::Definition::BaseOption
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(::EacCli::Definition::Error,
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module EacCli
4
4
  class Definition
5
- class BaseOption
5
+ class Option
6
6
  class InitializeArgsParser
7
7
  PROPERTIES = %i[short long description options].freeze
8
8
  attr_reader(*PROPERTIES)
@@ -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 PositionalArgument
8
+ class Positional < ::EacCli::Definition::OptionOrPositional
8
9
  DEFAULT_REQUIRED = true
9
10
  DEFAULT_VISIBLE = true
10
11
 
11
- enable_listable
12
- lists.add_symbol :option, :optional, :repeat, :required, :subcommand, :visible
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
- def optional?
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
- def to_s
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
@@ -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/positional_argument'
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
- def alt(&block)
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[new_alternative_key] = r
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
@@ -4,10 +4,12 @@ module EacCli
4
4
  class Parser
5
5
  class Alternative
6
6
  module Argv
7
+ # @return [Enumerator<String>]
7
8
  def argv_enum
8
9
  @argv_enum ||= argv.each
9
10
  end
10
11
 
12
+ # @return [Boolean]
11
13
  def argv_pending?
12
14
  argv_enum.ongoing?
13
15
  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
- # @return [EacCli::Definition::BaseOption] The option collected.
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 [OpenStruct]
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_exts'
3
+ require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module EacCli
6
6
  module Rspec
@@ -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) # rubocop:disable Rails/Exit
32
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
33
33
  end
34
34
  end
35
35
  end
@@ -20,6 +20,12 @@ module EacCli
20
20
  columns.map(&:to_s)
21
21
  end
22
22
 
23
+ # @param row [Object]
24
+ # @return [Object]
25
+ def build_row(_row)
26
+ raise_abstract_method __method__
27
+ end
28
+
23
29
  # @return [Array<Hash<String, String>>]
24
30
  def build_rows
25
31
  rows.map { |row| build_row(row) }
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/runner_with/output_list/base_formatter'
5
+ require 'tty/table'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module OutputList
10
+ class TtyFormatter < ::EacCli::RunnerWith::OutputList::BaseFormatter
11
+ # @param row [Object]
12
+ # @return [Array]
13
+ def build_row(row)
14
+ build_columns.map { |c| row.send(c) }
15
+ end
16
+
17
+ # @return [String]
18
+ def to_output
19
+ "#{tty_table_output}\n"
20
+ end
21
+
22
+ # @return [TTY::Table]
23
+ def tty_table
24
+ ::TTY::Table.new(build_columns, build_rows)
25
+ end
26
+
27
+ # @return [String]
28
+ def tty_table_output
29
+ tty_table.render(:unicode, multiline: true) do |renderer|
30
+ renderer.border.separator = ->(row) { ((row + 1) % columns.count).zero? }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -11,6 +11,7 @@ module EacCli
11
11
 
12
12
  FORMATS = {
13
13
  'csv' => ::EacCli::RunnerWith::OutputList::CsvFormatter,
14
+ 'tty' => ::EacCli::RunnerWith::OutputList::TtyFormatter,
14
15
  'yaml' => ::EacCli::RunnerWith::OutputList::YamlFormatter
15
16
  }.freeze
16
17
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.38.0'
4
+ VERSION = '0.39.0'
5
5
  end
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.0
4
+ version: 0.39.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-10-14 00:00:00.000000000 Z
11
+ date: 2023-11-18 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
@@ -64,20 +70,34 @@ dependencies:
64
70
  - - ">="
65
71
  - !ruby/object:Gem::Version
66
72
  version: 0.119.2
73
+ - !ruby/object:Gem::Dependency
74
+ name: tty-table
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.12'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.12'
67
87
  - !ruby/object:Gem::Dependency
68
88
  name: eac_ruby_gem_support
69
89
  requirement: !ruby/object:Gem::Requirement
70
90
  requirements:
71
91
  - - "~>"
72
92
  - !ruby/object:Gem::Version
73
- version: 0.8.1
93
+ version: '0.9'
74
94
  type: :development
75
95
  prerelease: false
76
96
  version_requirements: !ruby/object:Gem::Requirement
77
97
  requirements:
78
98
  - - "~>"
79
99
  - !ruby/object:Gem::Version
80
- version: 0.8.1
100
+ version: '0.9'
81
101
  description:
82
102
  email:
83
103
  executables: []
@@ -95,12 +115,12 @@ files:
95
115
  - lib/eac_cli/definition.rb
96
116
  - lib/eac_cli/definition/alternative.rb
97
117
  - 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
118
  - lib/eac_cli/definition/boolean_option.rb
101
- - lib/eac_cli/definition/default_value.rb
102
119
  - lib/eac_cli/definition/error.rb
103
- - lib/eac_cli/definition/positional_argument.rb
120
+ - lib/eac_cli/definition/option.rb
121
+ - lib/eac_cli/definition/option/initialize_args_parser.rb
122
+ - lib/eac_cli/definition/option_or_positional.rb
123
+ - lib/eac_cli/definition/positional.rb
104
124
  - lib/eac_cli/enum.rb
105
125
  - lib/eac_cli/old_configs.rb
106
126
  - lib/eac_cli/old_configs/entry_reader.rb
@@ -152,6 +172,7 @@ files:
152
172
  - lib/eac_cli/runner_with/output_list.rb
153
173
  - lib/eac_cli/runner_with/output_list/base_formatter.rb
154
174
  - lib/eac_cli/runner_with/output_list/csv_formatter.rb
175
+ - lib/eac_cli/runner_with/output_list/tty_formatter.rb
155
176
  - lib/eac_cli/runner_with/output_list/yaml_formatter.rb
156
177
  - lib/eac_cli/runner_with/subcommands.rb
157
178
  - lib/eac_cli/runner_with/subcommands/definition_concern.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