eac_cli 0.38.1 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a58c5ccac3080dd986b2727ce365a7979a801f059016faa0f7fe8dd8b86e1d3
4
- data.tar.gz: 06cb591e776e862bfcbe048fb524f05a8bd06b3e85a86a14c28df40654355eba
3
+ metadata.gz: 7ece27189a8fbfde6ada6b7b3b1bbe78a57dd47cd2df0eba8cd1551fe94b5cee
4
+ data.tar.gz: 77046ab0fcdc365df212cfe028e953eec75d82f2ed0f4b7f148d62635d7a783f
5
5
  SHA512:
6
- metadata.gz: 3ebf30f86ad003589e75880af90d75058a55c9e76ed386f0a1972c175ed22c2ea8c135c765ff2cf1d7476591126eac66ea680b6f38c96a95a800069a140060fd
7
- data.tar.gz: 1d2ea1f751023f5a11e2ef8465bab272429e29088e27123830fae2cb041d7ce4524c931c08a2088597664edc638bf6eb775c7a8e2b6ede1af05e09fe02bc7d7f
6
+ metadata.gz: 825723db43e762a7445d7ba56e7c61fc9125d5355209608112009137937f43679cd460b9c45fcbcbd808a34db7f3986b257618ba6e702aa33ff01946f6251e8a
7
+ data.tar.gz: 843805718a773a90e3dc1030127bc4db0c073f4f304bd0c6b2140177697c74becebccfa755412f048528f30af9e362775b1cda7e87f73132c5d348b81b9ac182
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module RunnerWith
7
+ module Confirmation
8
+ class InputResult
9
+ INPUT_NO_FOR_ONE = 'n'
10
+ INPUT_NO_FOR_ALL = 'N'
11
+ INPUT_YES_FOR_ONE = 'y'
12
+ INPUT_YES_FOR_ALL = 'Y'
13
+ INPUT_FOR_ONE = [INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE].freeze
14
+ INPUT_FOR_ALL = [INPUT_NO_FOR_ALL, INPUT_YES_FOR_ALL].freeze
15
+ INPUT_NO = [INPUT_NO_FOR_ONE, INPUT_NO_FOR_ALL].freeze
16
+ INPUT_YES = [INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL].freeze
17
+ INPUT_LIST = [INPUT_NO_FOR_ALL, INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL]
18
+ .freeze
19
+
20
+ class << self
21
+ enable_speaker
22
+
23
+ # @param message [String]
24
+ # @return [EacCli::RunnerWith::Confirmation::InputResult]
25
+ def by_message(message)
26
+ new(input(message, list: INPUT_LIST))
27
+ end
28
+ end
29
+
30
+ common_constructor :input_value
31
+
32
+ # @return [Boolean]
33
+ def confirm?
34
+ input_value_to_bool(INPUT_NO, INPUT_YES)
35
+ end
36
+
37
+ # @return [Boolean]
38
+ def for_all?
39
+ input_value_to_bool(INPUT_FOR_ONE, INPUT_FOR_ALL)
40
+ end
41
+
42
+ private
43
+
44
+ # @param false_list [Array<String>]
45
+ # @param true_list [Array<String>]
46
+ # @return [Boolean]
47
+ def input_value_to_bool(false_list, true_list)
48
+ return false if false_list.include?(input_value)
49
+ return true if true_list.include?(input_value)
50
+
51
+ ibr input_value
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -19,13 +19,13 @@ module EacCli
19
19
  end
20
20
 
21
21
  def confirm?(message = nil)
22
+ return for_all_answers.fetch(message) if for_all_answers.key?(message)
22
23
  return false if parsed.no?
23
24
  return true if parsed.yes?
24
25
 
25
- input(
26
- message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
- bool: true
28
- )
26
+ r = confirm_input(message)
27
+ for_all_answers[message] = r.for_all?
28
+ r.confirm?
29
29
  rescue ::EacCli::Speaker::InputRequested => e
30
30
  fatal_error e.message
31
31
  end
@@ -39,6 +39,21 @@ module EacCli
39
39
  def cached_confirm_uncached?(message = nil)
40
40
  confirm?(message)
41
41
  end
42
+
43
+ # @param message [String, nil]
44
+ # @return [Boolean]
45
+ def confirm_input(message)
46
+ ::EacCli::RunnerWith::Confirmation::InputResult.by_message(
47
+ message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT)
48
+ )
49
+ end
50
+
51
+ # @return [Hash<String, Boolean>]
52
+ def for_all_answers_uncached
53
+ {}
54
+ end
55
+
56
+ require_sub __FILE__
42
57
  end
43
58
  end
44
59
  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.1'
4
+ VERSION = '0.40.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.1
4
+ version: 0.40.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-08 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -56,20 +56,28 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.119'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.119.2
59
+ version: '0.120'
63
60
  type: :runtime
64
61
  prerelease: false
65
62
  version_requirements: !ruby/object:Gem::Requirement
66
63
  requirements:
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
- version: '0.119'
70
- - - ">="
66
+ version: '0.120'
67
+ - !ruby/object:Gem::Dependency
68
+ name: tty-table
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.12'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
71
79
  - !ruby/object:Gem::Version
72
- version: 0.119.2
80
+ version: '0.12'
73
81
  - !ruby/object:Gem::Dependency
74
82
  name: eac_ruby_gem_support
75
83
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +153,7 @@ files:
145
153
  - lib/eac_cli/runner/instance_methods.rb
146
154
  - lib/eac_cli/runner_with.rb
147
155
  - lib/eac_cli/runner_with/confirmation.rb
156
+ - lib/eac_cli/runner_with/confirmation/input_result.rb
148
157
  - lib/eac_cli/runner_with/help.rb
149
158
  - lib/eac_cli/runner_with/help/builder.rb
150
159
  - lib/eac_cli/runner_with/help/builder/alternative.rb
@@ -158,6 +167,7 @@ files:
158
167
  - lib/eac_cli/runner_with/output_list.rb
159
168
  - lib/eac_cli/runner_with/output_list/base_formatter.rb
160
169
  - lib/eac_cli/runner_with/output_list/csv_formatter.rb
170
+ - lib/eac_cli/runner_with/output_list/tty_formatter.rb
161
171
  - lib/eac_cli/runner_with/output_list/yaml_formatter.rb
162
172
  - lib/eac_cli/runner_with/subcommands.rb
163
173
  - lib/eac_cli/runner_with/subcommands/definition_concern.rb