Sha256: 5bb726e624b53aad7ae0a51f57d03388c25606f891fc969929833d15133d46e6
Contents?: true
Size: 849 Bytes
Versions: 3
Compression:
Stored size: 849 Bytes
Contents
# frozen_string_literal: true require_relative '../command' require 'tty-prompt' require 'launchy' module Dri module Commands class FAQ < Dri::Command ExitCommand = Class.new(StandardError) def execute(input: $stdin, output: $stdout) root_dir = File.expand_path('../../..', __dir__) faq_file = File.join(root_dir, 'faq.yaml') faq_data = YAML.load_file(faq_file) prompt = TTY::Prompt.new choices = faq_data.map { |entry| { name: entry['question'], value: entry['link'] } } url = prompt.select("Select a question:", choices) raise ExitCommand if url.nil? || url.strip.empty? begin Launchy.open(url) rescue Launchy::Error => e puts "Failed to open URL: #{e.message}" raise ExitCommand end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dri-0.10.2 | lib/dri/commands/faq.rb |
dri-0.10.1 | lib/dri/commands/faq.rb |
dri-0.10.0 | lib/dri/commands/faq.rb |