2024-10-01 05:44:21 +01:00
|
|
|
package executors
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"codeflow.dananglin.me.uk/apollo/gator/internal/state"
|
|
|
|
)
|
|
|
|
|
2024-10-03 03:37:52 +01:00
|
|
|
func users(s *state.State, _ executor) error {
|
2024-10-01 05:44:21 +01:00
|
|
|
users, err := s.DB.GetAllUsers(context.Background())
|
|
|
|
if err != nil {
|
|
|
|
fmt.Errorf("unable to get the users from the database: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(users) == 0 {
|
|
|
|
fmt.Println("There are no registered users.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Registered users:\n\n")
|
|
|
|
|
|
|
|
for _, user := range users {
|
|
|
|
if user.Name == s.Config.CurrentUsername {
|
|
|
|
fmt.Printf("- %s (current)\n", user.Name)
|
|
|
|
} else {
|
|
|
|
fmt.Printf("- %s\n", user.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|