class UI::Interactive
Public Instance Methods
create_task(title, &block)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 17 def create_task(title, &block) init_if_needed CLI::UI::Spinner.spin(title, &block) end
create_task_group()
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 12 def create_task_group init_if_needed TaskGroup.new end
print_debug(title, text)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 35 def print_debug(title, text) logger.debug(text) end
print_error(title, text)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 26 def print_error(title, text) print_in_frame(title, text, color: :red) end
print_info(title, text)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 22 def print_info(title, text) print_in_frame(title, text, color: :blue) end
print_result(message, data = {})
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 39 def print_result(message, data = {}) print_debug("Result", "---------------------------") print_debug("Result", message) print_debug("Result", "---------------------------") end
print_warning(title, text)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 30 def print_warning(title, text) print_in_frame(title, text, color: :yellow) logger.debug(text) end
prompt(text, options, &callback)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 45 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 Instance Methods
init()
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 53 def init @initialized = true ::CLI::UI::StdoutRouter.enable end
init_if_needed()
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 58 def init_if_needed init unless @initialized end
print_in_frame(title, text, color:)
click to toggle source
# File lib/kuber_kit/ui/interactive.rb, line 62 def print_in_frame(title, text, color:) CLI::UI::Frame.open(title, color: color) do puts text end end