diff --git a/pkg/cli/cmd.go b/pkg/cli/cmd.go index 1cdc770..5fb87a1 100644 --- a/pkg/cli/cmd.go +++ b/pkg/cli/cmd.go @@ -25,7 +25,7 @@ var lsCmd = &cobra.Command{ Short: "List existing conversations", Long: `List all existing conversations in descending order of recent activity.`, Run: func(cmd *cobra.Command, args []string) { - conversations, err := store.GetConversations() + conversations, err := store.Conversations() if err != nil { fmt.Println("Could not fetch conversations.") return @@ -64,7 +64,7 @@ var lsCmd = &cobra.Command{ categorized := map[string][]string{} for _, conversation := range conversations { - lastMessage, err := store.GetLastMessage(&conversation) + lastMessage, err := store.LastMessage(&conversation) if lastMessage == nil || err != nil { continue } @@ -128,7 +128,7 @@ var viewCmd = &cobra.Command{ Fatal("Conversation not found with short name: %s\n", shortName) } - messages, err := store.GetMessages(conversation) + messages, err := store.Messages(conversation) if err != nil { Fatal("Could not retrieve messages for conversation: %s\n", conversation.Title) } diff --git a/pkg/cli/store.go b/pkg/cli/store.go index 63ce9f6..417a4ff 100644 --- a/pkg/cli/store.go +++ b/pkg/cli/store.go @@ -90,7 +90,7 @@ func (s *Store) SaveMessage(message *Message) error { return s.db.Create(message).Error } -func (s *Store) GetConversations() ([]Conversation, error) { +func (s *Store) Conversations() ([]Conversation, error) { var conversations []Conversation err := s.db.Find(&conversations).Error return conversations, err @@ -98,7 +98,7 @@ func (s *Store) GetConversations() ([]Conversation, error) { func (s *Store) ConverstionShortNameCompletions(shortName string) []string { var completions []string - conversations, _ := s.GetConversations() // ignore error for completions + conversations, _ := s.Conversations() // ignore error for completions for _, conversation := range conversations { if shortName == "" || strings.HasPrefix(conversation.ShortName.String, shortName) { completions = append(completions, fmt.Sprintf("%s\t%s", conversation.ShortName.String, conversation.Title)) @@ -113,13 +113,13 @@ func (s *Store) ConversationByShortName(shortName string) (*Conversation, error) return &conversation, err } -func (s *Store) GetMessages(conversation *Conversation) ([]Message, error) { +func (s *Store) Messages(conversation *Conversation) ([]Message, error) { var messages []Message err := s.db.Where("conversation_id = ?", conversation.ID).Find(&messages).Error return messages, err } -func (s *Store) GetLastMessage(conversation *Conversation) (*Message, error) { +func (s *Store) LastMessage(conversation *Conversation) (*Message, error) { var message Message err := s.db.Where("conversation_id = ?", conversation.ID).Last(&message).Error return &message, err