2023-10-25 04:39:13 +00:00
|
|
|
package main
|
|
|
|
|
2023-10-25 08:24:23 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2023-10-25 04:39:13 +00:00
|
|
|
|
2023-10-25 08:24:23 +00:00
|
|
|
"git.tilde.town/tildetown/town/towndb"
|
|
|
|
)
|
|
|
|
|
|
|
|
func _main(args []string) error {
|
|
|
|
if len(args) < 2 {
|
|
|
|
return errors.New("need email")
|
|
|
|
}
|
|
|
|
email := args[1]
|
|
|
|
|
|
|
|
db, err := towndb.ConnectDB()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
user, err := towndb.UserForEmail(db, email)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if user == nil {
|
|
|
|
return errors.New("email does not correspond to user")
|
|
|
|
}
|
|
|
|
|
2023-10-25 19:24:01 +00:00
|
|
|
fmt.Print(user.Username)
|
2023-10-25 08:24:23 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2023-10-25 04:39:13 +00:00
|
|
|
|
|
|
|
func main() {
|
2023-10-25 08:24:23 +00:00
|
|
|
if err := _main(os.Args); err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2023-10-25 04:39:13 +00:00
|
|
|
}
|