eac_cli 0.30.0 → 0.31.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: 1c6c9d3ac7f26ac1fdc4cbb83a5c7c6b36bd9b293429b17ca63b25b3945d562e
4
- data.tar.gz: a887a446a8f97edc9c2d4d093a22251a2e51cf47c5656c661c47530d3d3a0c51
3
+ metadata.gz: 52da9c5cfc7914cd5779c7d4f4e623a22c39e2132b1b15e4f390876a3101f62e
4
+ data.tar.gz: f226519347c7afb6e98377af26efd8c502eb9fb3dfe13adfa06c41e60dfcd83c
5
5
  SHA512:
6
- metadata.gz: 371e1ab8cb6b93c36ad658168212c344c2c14e92ee783d91fc7d6251b21c85122284e800f1c1797b130df8bee6701e262e50e0894c018108bc55dfc91ba8cada
7
- data.tar.gz: 7361269780fce5f667541fee9fe3ebbb1248b9335e59f1529f9099872fd0985635197b3c41cfc25f232a921b02c29067e28393983c6e55aba121129343d21ddc
6
+ metadata.gz: 26a41f87f06e3e365db2ec3f517be9fe6770fa1682fbb420f567c68dcc5011c3185656c14bfa0d4faa9718b9250de4ff8c3b5527efcbd8740ea3f1e21607ee6f
7
+ data.tar.gz: 2cc2ffd7ef77d57c68f3996963da7b6fb2afcb592fa4779a1c69ed348a3b65672e49f7ee60e79bfdbbcc5f33ececa4f4c0d0b222784003538d44c8aa2191c34f
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module Confirmation
9
+ DEFAULT_CONFIRM_QUESTION_TEXT = 'Confirm?'
10
+
11
+ common_concern do
12
+ include ::EacCli::Runner
13
+ enable_settings_provider
14
+ enable_simple_cache
15
+ runner_definition do
16
+ bool_opt '--no', 'Deny confirmation without question.'
17
+ bool_opt '--yes', 'Accept confirmation without question.'
18
+ end
19
+ end
20
+
21
+ def confirm?(message = nil)
22
+ return false if parsed.no?
23
+ return true if parsed.yes?
24
+
25
+ input(
26
+ message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
+ bool: true
28
+ )
29
+ rescue ::EacCli::Speaker::InputRequested => e
30
+ fatal_error e.message
31
+ end
32
+
33
+ def run_confirm(message = nil)
34
+ yield if confirm?(message)
35
+ end
36
+
37
+ private
38
+
39
+ def cached_confirm_uncached?(message = nil)
40
+ confirm?(message)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/abstract_methods'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module Input
10
+ STDIN_OPTION = '-'
11
+ BLANK_OPTION = '+'
12
+ DEFAULT_DEFAULT_INPUT_OPTION = BLANK_OPTION
13
+
14
+ common_concern do
15
+ enable_settings_provider
16
+ include ::EacCli::Runner
17
+
18
+ runner_definition do
19
+ arg_opt '-i', '--input', 'Input from file.'
20
+ end
21
+ end
22
+
23
+ def input_content
24
+ case input_option
25
+ when STDIN_OPTION then $stdin.read
26
+ when BLANK_OPTION then ''
27
+ else input_option.to_pathname.read
28
+ end
29
+ end
30
+
31
+ def input_option
32
+ parsed.input || setting_value(:default_input_option, default: DEFAULT_DEFAULT_INPUT_OPTION)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/abstract_methods'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module Output
10
+ STDOUT_OPTION = '-'
11
+ DEFAULT_FILE_OPTION = '+'
12
+ DEFAULT_DEFAULT_OUTPUT_OPTION = STDOUT_OPTION
13
+ DEFAULT_DEFAULT_FILE_TO_OUTPUT = 'output'
14
+
15
+ common_concern do
16
+ enable_abstract_methods
17
+ enable_settings_provider
18
+ include ::EacCli::Runner
19
+
20
+ abstract_methods :output_content
21
+
22
+ runner_definition do
23
+ arg_opt '-o', '--output', 'Output to file.'
24
+ end
25
+ end
26
+
27
+ def run_output
28
+ file = file_to_output
29
+ if file
30
+ file.to_pathname.write(output_content)
31
+ else
32
+ $stdout.write(output_content)
33
+ end
34
+ end
35
+
36
+ def output_option
37
+ parsed.output || default_output_option_value
38
+ end
39
+
40
+ def file_to_output
41
+ case output_option
42
+ when STDOUT_OPTION then nil
43
+ when DEFAULT_FILE_OPTION then default_file_to_output_value
44
+ else output_option
45
+ end
46
+ end
47
+
48
+ def default_output_option_value
49
+ setting_value(:default_output_option,
50
+ default: DEFAULT_DEFAULT_OUTPUT_OPTION)
51
+ end
52
+
53
+ def default_file_to_output_value
54
+ setting_value(:default_file_to_output, default: DEFAULT_DEFAULT_FILE_TO_OUTPUT)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/gems_registry'
4
+
3
5
  module EacCli
4
6
  class RunnerWithSet
5
7
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.30.0'
4
+ VERSION = '0.31.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.30.0
4
+ version: 0.31.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: 2022-11-11 00:00:00.000000000 Z
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -50,20 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.107'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.107.1
53
+ version: '0.112'
57
54
  type: :runtime
58
55
  prerelease: false
59
56
  version_requirements: !ruby/object:Gem::Requirement
60
57
  requirements:
61
58
  - - "~>"
62
59
  - !ruby/object:Gem::Version
63
- version: '0.107'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.107.1
60
+ version: '0.112'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: eac_ruby_gem_support
69
63
  requirement: !ruby/object:Gem::Requirement
@@ -128,9 +122,12 @@ files:
128
122
  - lib/eac_cli/runner/exit.rb
129
123
  - lib/eac_cli/runner/instance_methods.rb
130
124
  - lib/eac_cli/runner_with.rb
125
+ - lib/eac_cli/runner_with/confirmation.rb
131
126
  - lib/eac_cli/runner_with/help.rb
132
127
  - lib/eac_cli/runner_with/help/builder.rb
133
128
  - lib/eac_cli/runner_with/help/builder/alternative.rb
129
+ - lib/eac_cli/runner_with/input.rb
130
+ - lib/eac_cli/runner_with/output.rb
134
131
  - lib/eac_cli/runner_with/subcommands.rb
135
132
  - lib/eac_cli/runner_with/subcommands/definition_concern.rb
136
133
  - lib/eac_cli/runner_with_set.rb