Add fetch, pick, body, output primitives

fetch: loading-indicator + ctx store for API calls
pick: numbered list with selection and sub-flow drill-down
body: word-wrapped article text (strip markdown, reflow)
output: raw string block for complex multi-line content

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 09:27:45 +02:00
parent 272e75bd6f
commit c01159dc23
2 changed files with 123 additions and 0 deletions

View File

@@ -99,6 +99,25 @@ module BBS
def wait_enter(prompt: 'Press ENTER to continue...')
@steps << { type: :wait_enter, prompt: prompt }
end
def fetch(name, loading: 'Loading...', &block)
@steps << { type: :fetch, name: name, loading: loading, block: block }
end
def pick(from:, prompt:, empty: 'No items.', item:, hint: nil, &block)
sub = Flow.new
sub.instance_eval(&block) if block_given?
@steps << { type: :pick, from: from, prompt: prompt, empty: empty,
item: item, hint: hint, sub_steps: sub.steps }
end
def body(width: 66, indent: 4, &block)
@steps << { type: :body, block: block, width: width, indent: indent }
end
def output(&block)
@steps << { type: :output, block: block }
end
end
class MenuBuilder