Class: Exa::CLI::Formatters::WebsetSearchFormatter
- Inherits:
-
Object
- Object
- Exa::CLI::Formatters::WebsetSearchFormatter
- Defined in:
- lib/exa/cli/formatters/webset_search_formatter.rb
Class Method Summary collapse
Class Method Details
.format(search, format) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/exa/cli/formatters/webset_search_formatter.rb', line 7 def self.format(search, format) case format when "json" JSON.pretty_generate(search.to_h) when "pretty" format_pretty(search) when "text" format_text(search) when "toon" Exa::CLI::Base.encode_as_toon(search.to_h) else JSON.pretty_generate(search.to_h) end end |
.format_pretty(search) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/exa/cli/formatters/webset_search_formatter.rb', line 24 def self.format_pretty(search) output = [] output << "Search ID: #{search.id}" output << "Status: #{search.status}" output << "Query: #{search.query}" output << "Entity Type: #{search.entity&.[]('type') || 'N/A'}" if search.entity output << "Count: #{search.count}" if search.count output << "Behavior: #{search.behavior}" output << "Recall: #{search.recall}" if search.recall output << "Created: #{search.created_at}" output << "Updated: #{search.updated_at}" output << "Progress: #{search.progress}" if search.progress output << "" if search.canceled? output << "Canceled: #{search.canceled_at}" output << "Cancel Reason: #{search.canceled_reason}" if search.canceled_reason end output.join("\n") end |
.format_text(search) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/exa/cli/formatters/webset_search_formatter.rb', line 46 def self.format_text(search) [ "ID: #{search.id}", "Status: #{search.status}", "Query: #{search.query}", "Behavior: #{search.behavior}" ].join("\n") end |