forked from tildetown/town
fill in emailtouser
parent
be5020ad28
commit
b1ff57ba58
|
@ -11,3 +11,4 @@ cmd/registeruser/registeruser
|
|||
cmd/stats/stats
|
||||
cmd/appendkeyfile/appendkeyfile
|
||||
cmd/help/help
|
||||
cmd/emailtouser/emailtouser
|
||||
|
|
|
@ -1,9 +1,40 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
// TODO accept an email as an argument, write out a username associated with it or throw an error
|
||||
"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")
|
||||
}
|
||||
|
||||
fmt.Println(user.Username)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("TODO")
|
||||
if err := _main(os.Args); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue