Add search command

This commit is contained in:
Jorge Manrubia
2025-06-25 07:48:02 +02:00
parent 1ce8d8bff0
commit c319c49345
5 changed files with 30 additions and 13 deletions
-8
View File
@@ -12,14 +12,6 @@ class Command::GetInsight < Command
Command::Result::InsightResponse.new(response.content)
end
def undoable?
false
end
def needs_confirmation?
false
end
private
def chat
chat = RubyLLM.chat
+7 -4
View File
@@ -18,6 +18,7 @@ class Command::Parser
private
def parse_command(string)
command_name, *command_arguments = string.strip.split(" ")
combined_arguments = command_arguments.join(" ")
case command_name
when /^#/
@@ -26,16 +27,18 @@ class Command::Parser
Command::GoToUser.new(user_id: assignee_from(command_name)&.id)
when "/assign", "/assignto"
Command::Assign.new(assignee_ids: assignees_from(command_arguments).collect(&:id), card_ids: cards.ids)
when "/insight"
Command::GetInsight.new(query: command_arguments.join(" "), card_ids: cards.ids)
when "/clear"
Command::ClearFilters.new(params: filter.as_params)
when "/close"
Command::Close.new(card_ids: cards.ids, reason: command_arguments.join(" "))
Command::Close.new(card_ids: cards.ids, reason: combined_arguments)
when "/insight"
Command::GetInsight.new(query: combined_arguments, card_ids: cards.ids)
when "/search"
Command::Search.new(terms: combined_arguments)
when "/visit"
Command::VisitUrl.new(url: command_arguments.first)
when "/tag"
Command::Tag.new(tag_title: tag_title_from(command_arguments.join(" ")), card_ids: cards.ids)
Command::Tag.new(tag_title: tag_title_from(combined_arguments), card_ids: cards.ids)
else
parse_free_string(string)
end
+11
View File
@@ -0,0 +1,11 @@
class Command::Search < Command
store_accessor :data, :terms
def title
"Search '#{terms}'"
end
def execute
redirect_to search_path(q: terms)
end
end
+1 -1
View File
@@ -12,7 +12,7 @@
<dd>Just show cards taggged [tag]</dd>
<dt><code>[id] [id]…</code></dt>
<dd>Show multiple cards by ID</dd>
<dt><code>[search term]</code></dt>
<dt><code>[/search term]</code></dt>
<dd>Keyword search</dd>
<dt><code>/clear</code></dt>
<dd>Clear all filters</dd>
+11
View File
@@ -0,0 +1,11 @@
require "test_helper"
class Command::SearchTest < ActionDispatch::IntegrationTest
include CommandTestHelper
test "redirect to the user perma" do
result = execute_command "/search something"
assert_equal search_path(q: "something"), result.url
end
end