Sha256: d72596c5b908a7708b675821e163dc867ef8b6e6a3fa80afcc962a820ccb8574

Contents?: true

Size: 809 Bytes

Versions: 10

Compression:

Stored size: 809 Bytes

Contents

require 'cli/ui'

class KuberKit::UI::Interactive
  class TaskGroup < CLI::UI::SpinGroup
  end

  def create_task_group
    init_if_needed
    TaskGroup.new
  end

  def create_task(title, &block)
    init_if_needed
    CLI::UI::Spinner.spin(title, &block)
  end

  def print_info(title, text)
    print_in_frame(title, text, color: :blue)
  end

  def print_error(title, text)
    print_in_frame(title, text, color: :red)
  end

  def print_warning(title, text)
    print_in_frame(title, text, color: :yellow)
  end

  private
    def init
      @initialized = true
      ::CLI::UI::StdoutRouter.enable
    end

    def init_if_needed
      init unless @initialized
    end

    def print_in_frame(title, text, color:)
      CLI::UI::Frame.open(title, color: color) do
        puts text
      end
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuber_kit-0.1.9 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.8 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.7 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.6 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.5 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.4 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.3 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.2 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.1 lib/kuber_kit/ui/interactive.rb
kuber_kit-0.1.0 lib/kuber_kit/ui/interactive.rb