Class: Slidict::CLI
- Inherits:
-
Object
- Object
- Slidict::CLI
- Defined in:
- lib/slidict/cli.rb
Constant Summary collapse
- DEFAULT_OUTPUT =
"slides.md"
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout, renderer: MarkdownRenderer.new) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv = []) ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout, renderer: MarkdownRenderer.new) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 |
# File 'lib/slidict/cli.rb', line 7 def initialize(input: $stdin, output: $stdout, renderer: MarkdownRenderer.new) @input = input @output = output @renderer = renderer end |
Instance Method Details
#run(argv = []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/slidict/cli.rb', line 13 def run(argv = []) = parse(argv) return print_help if [:help] config = build_config() client = llm_client_for(config) return 1 if client && !verify_connection(client) deck = Deck.new( topic: ask("What would you like to talk about?", [:topic]), duration: ask("How long is the presentation?", [:duration]), audience: ask("Who is the audience?", [:audience]), goal: ask("What should the audience remember or do?", [:goal]), framework: [:framework] ) if client begin = client.(deck) rescue LLMClient::Error => error @output.puts "Error: LLM request failed (#{error.})" return 1 end deck = Deck.new( topic: deck.topic, duration: deck.duration, audience: deck.audience, goal: deck.goal, framework: deck.framework, slides: ) end path = [:output] File.write(path, @renderer.render(deck)) @output.puts "Created #{path}" 0 rescue ArgumentError => error @output.puts "Error: #{error.}" @output.puts print_help 1 end |