#5 - list users

This commit is contained in:
2025-03-11 12:23:58 +02:00
parent 79b0812a90
commit e74d33ab55
5 changed files with 76 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package handlers
import (
"context"
"fmt"
"github.com/rdarius/boot-dev-blog-aggregator/internal/config"
"os"
)
func GetUsersHandler(s *config.State, cmd config.Command) error {
ctx := context.Background()
u, err := s.DB.GetUsers(ctx)
if err != nil {
fmt.Println("Failed to get Users")
os.Exit(1)
}
for _, u := range u {
fmt.Printf("* %s", u.Name)
if u.Name == s.Config.CurrentUserName {
fmt.Print(" (current)")
}
fmt.Print("\n")
}
return nil
}