Module: Rfd::HelpGenerator
- Defined in:
- lib/rfd/help_generator.rb
Constant Summary collapse
- CACHE_FILE =
File.join(__dir__, 'help.txt')
Class Method Summary collapse
Class Method Details
.build ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rfd/help_generator.rb', line 18 def build comments, lines = parse_comments, [] Rfd::Commands.categories.each do |category| entries = build_entries_for(category, comments) next if entries.empty? display_name = category.name.split('::').last.gsub(/([a-z])([A-Z])/, '\1 \2') lines << display_name entries.each do |entry| lines << format(' %-14s %s', entry[:key], entry[:description]) end lines << '' end lines << 'Environment: RFD_NO_ICONS=1 to disable file icons (icons require Nerd Font)' lines.join("\n") end |
.generate ⇒ Object
11 12 13 14 15 16 |
# File 'lib/rfd/help_generator.rb', line 11 def generate # Use cached file if available return File.read(CACHE_FILE) if File.exist?(CACHE_FILE) build end |
.write_cache ⇒ Object
37 38 39 |
# File 'lib/rfd/help_generator.rb', line 37 def write_cache File.write(CACHE_FILE, build) end |