Class: Askcii::Commands::ClearHistoryCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Askcii::Commands::ClearHistoryCommand
- Defined in:
- lib/askcii/commands/clear_history_command.rb
Overview
Clears conversation history for the current session
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from Askcii::Commands::BaseCommand
Instance Method Details
#execute ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/askcii/commands/clear_history_command.rb', line 7 def execute verbose "Clearing history for session: #{session_context}" chat = Chat.find(context: session_context) unless chat puts "No session found to clear." exit 0 end = chat..count # Delete all messages for this chat chat..delete # Delete the chat itself chat.delete puts "Cleared session '#{session_context}' (#{message_count} messages removed)" exit 0 end |