gator/internal/executors/following.go
Dan Anglin 15386cdb9f
refactor: move executorfunc map
Move the executorFunc map to internal/executors.
2024-10-03 03:37:52 +01:00

30 lines
632 B
Go

package executors
import (
"context"
"fmt"
"codeflow.dananglin.me.uk/apollo/gator/internal/database"
"codeflow.dananglin.me.uk/apollo/gator/internal/state"
)
func following(s *state.State, _ executor, user database.User) error {
following, err := s.DB.GetFeedFollowsForUser(context.Background(), user.ID)
if err != nil {
return fmt.Errorf("unable to get the list of feeds from the database: %w", err)
}
if len(following) == 0 {
fmt.Println("You are not following any feeds.")
return nil
}
fmt.Printf("\nYou are following:\n\n")
for _, feed := range following {
fmt.Printf("- %s\n", feed)
}
return nil
}