Sha256: bdba97df2d6c13e93c832a0558aa3283fed502a8259a87d129d4cd8d4f139db7
Contents?: true
Size: 1.36 KB
Versions: 67
Compression:
Stored size: 1.36 KB
Contents
require 'cli/ui' require "tty-prompt" class KuberKit::UI::Interactive include KuberKit::Import[ "tools.logger", ] 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) logger.debug(text) end def print_debug(title, text) logger.debug(text) end def print_result(message, data = {}) print_debug("Result", "---------------------------") print_debug("Result", message) print_debug("Result", "---------------------------") end def prompt(text, options, &callback) prompt = TTY::Prompt.new prompt.select(text, options, filter: true, per_page: 10) rescue TTY::Reader::InputInterrupt raise KuberKit::Error.new("Selection cancelled.") 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
67 entries across 67 versions & 1 rubygems