47 lines
843 B
Ruby
47 lines
843 B
Ruby
# frozen_string_literal: true
|
|
|
|
module FeatherCaseWizard
|
|
class PromptingUI
|
|
def self.wrap(ui)
|
|
ui.is_a?(self) ? ui : new(ui)
|
|
end
|
|
|
|
def initialize(ui)
|
|
@ui = ui
|
|
end
|
|
|
|
def ask(*arguments, &block)
|
|
separate_after { @ui.ask(*arguments, &block) }
|
|
end
|
|
|
|
def agree(*arguments, &block)
|
|
separate_after { @ui.agree(*arguments, &block) }
|
|
end
|
|
|
|
def choose(prompt, &block)
|
|
separate_after do
|
|
@ui.choose do |menu|
|
|
menu.header = prompt.to_s.sub(/[?:]\s*\z/, "")
|
|
block.call(menu)
|
|
end
|
|
end
|
|
end
|
|
|
|
def say(*arguments, &block)
|
|
@ui.say(*arguments, &block)
|
|
end
|
|
|
|
def color(*arguments, &block)
|
|
@ui.color(*arguments, &block)
|
|
end
|
|
|
|
private
|
|
|
|
def separate_after
|
|
result = yield
|
|
@ui.say("\n")
|
|
result
|
|
end
|
|
end
|
|
end
|