eac_cli 0.30.1 → 0.31.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: d8bb5a28b8f6905c8e8fe31a46ea1ef51aa53f40efc5754328b299414aebbd86
4
- data.tar.gz: a3d0083739d15bbda74e05db8043441c254c14435532d279f3a8579bffb6bbf1
3
+ metadata.gz: 52da9c5cfc7914cd5779c7d4f4e623a22c39e2132b1b15e4f390876a3101f62e
4
+ data.tar.gz: f226519347c7afb6e98377af26efd8c502eb9fb3dfe13adfa06c41e60dfcd83c
5
5
  SHA512:
6
- metadata.gz: 5eb7b2c0629d9e2b7929ad9665a1372f52f5524c7761940370a3b9491a16c1799bb261fb822c85d54e5b811e5e6a72cce82f360cb88782accf8edee04dd742fa
7
- data.tar.gz: 58af9e3a6f0d69be373c6b8e118ddf44778b8304edb016632debe407fb3918d0339b03f8cb5ce55982328f805014a1006683fd3e4bc5fab66ad7f51101d5a2ba
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,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.30.1'
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.1
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: 2023-01-29 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
@@ -122,9 +122,12 @@ files:
122
122
  - lib/eac_cli/runner/exit.rb
123
123
  - lib/eac_cli/runner/instance_methods.rb
124
124
  - lib/eac_cli/runner_with.rb
125
+ - lib/eac_cli/runner_with/confirmation.rb
125
126
  - lib/eac_cli/runner_with/help.rb
126
127
  - lib/eac_cli/runner_with/help/builder.rb
127
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
128
131
  - lib/eac_cli/runner_with/subcommands.rb
129
132
  - lib/eac_cli/runner_with/subcommands/definition_concern.rb
130
133
  - lib/eac_cli/runner_with_set.rb