Class: Slidict::Cli::App
- Inherits:
-
Object
- Object
- Slidict::Cli::App
- Defined in:
- lib/slidict/cli/app.rb
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout, renderer: Output::Renderer.new, auth_client: nil, credentials: nil, sleeper: Kernel, slides_command: nil, server: nil, lint_command: nil) ⇒ App
constructor
A new instance of App.
- #run(argv = []) ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout, renderer: Output::Renderer.new, auth_client: nil, credentials: nil, sleeper: Kernel, slides_command: nil, server: nil, lint_command: nil) ⇒ App
Returns a new instance of App.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/slidict/cli/app.rb', line 9 def initialize(input: $stdin, output: $stdout, renderer: Output::Renderer.new, auth_client: nil, credentials: nil, sleeper: Kernel, slides_command: nil, server: nil, lint_command: nil) @input = input @output = output @renderer = renderer @auth_client = auth_client @credentials = credentials @sleeper = sleeper @slides_command = @server = server @lint_command = lint_command end |
Instance Method Details
#run(argv = []) ⇒ Object
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/slidict/cli/app.rb', line 22 def run(argv = []) = parse(argv) return print_help if [:help] return auth if [:command] == "auth" return ([:args]) if [:command] == "slides" return serve([:args]) if [:command] == "serve" return lint([:args]) if [:command] == "lint" config = build_config() return print_available_models(config) if config.llm_enabled? && config.model.nil? 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 Llm::Client::Error => e @output.puts "Error: LLM request failed (#{e.})" 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] content = @renderer.render(deck) FileUtils.mkdir_p(File.dirname(path)) File.write(path, content) @output.puts "Created #{path}" return publish_to_slidict(deck, content, ) if [:publish] || [:slide_id] 0 rescue ArgumentError => e @output.puts "Error: #{e.}" @output.puts print_help 1 end |