Class: PDK::CLI::ExecGroup
- Inherits:
-
Object
- Object
- PDK::CLI::ExecGroup
- Defined in:
- lib/pdk/cli/exec_group.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Instance Method Summary collapse
- #add_spinner(message, opts = {}) ⇒ Object
- #exit_code ⇒ Object
-
#initialize(message, opts = {}) ⇒ ExecGroup
constructor
A new instance of ExecGroup.
- #register ⇒ Object
Constructor Details
#initialize(message, opts = {}) ⇒ ExecGroup
Returns a new instance of ExecGroup.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pdk/cli/exec_group.rb', line 11 def initialize(, opts = {}) @options = opts.merge(PDK::CLI::Util.spinner_opts_for_platform) if PDK::CLI::Util.interactive? @multi_spinner = TTY::Spinner::Multi.new("[:spinner] #{}", @options) @multi_spinner.auto_spin end @threads = [] @exit_codes = [] end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
9 10 11 |
# File 'lib/pdk/cli/exec_group.rb', line 9 def commands @commands end |
Instance Method Details
#add_spinner(message, opts = {}) ⇒ Object
33 34 35 36 |
# File 'lib/pdk/cli/exec_group.rb', line 33 def add_spinner(, opts = {}) return unless PDK::CLI::Util.interactive? @multi_spinner.register("[:spinner] #{}", @options.merge(opts).merge(PDK::CLI::Util.spinner_opts_for_platform)) end |
#exit_code ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pdk/cli/exec_group.rb', line 38 def exit_code @threads.each(&:join) exit_code = @exit_codes.max if exit_code.zero? && @multi_spinner @multi_spinner.success elsif @multi_spinner @multi_spinner.error end exit_code end |
#register ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/pdk/cli/exec_group.rb', line 23 def register raise PDK::CLI::FatalError, 'No block registered' unless block_given? @threads << Thread.new do GettextSetup.initialize(File.absolute_path('../../../locales', File.dirname(__FILE__))) GettextSetup.negotiate_locale!(GettextSetup.candidate_locales) @exit_codes << yield end end |