Add subcommand to find a user
This commit is contained in:
parent
c22cf9e7c8
commit
452048359a
5 changed files with 47 additions and 7 deletions
29
cmd/find_user/main.go
Normal file
29
cmd/find_user/main.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package find_user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.a71.su/Andrew71/pye/config"
|
||||
"git.a71.su/Andrew71/pye/storage"
|
||||
"git.a71.su/Andrew71/pye/storage/sqlite"
|
||||
)
|
||||
|
||||
func FindUser(mode, query string) {
|
||||
data := sqlite.MustLoadSQLite(config.Cfg.SQLiteFile)
|
||||
var user storage.User
|
||||
var ok bool
|
||||
if mode == "email" {
|
||||
user, ok = data.ByEmail(query)
|
||||
} else if mode == "uuid" {
|
||||
user, ok = data.ById(query)
|
||||
} else {
|
||||
fmt.Println("expected email or uuid")
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
fmt.Println("User not found")
|
||||
} else {
|
||||
fmt.Printf("Information for user:\nuuid\t- %s\nemail\t- %s\nhash\t- %s\n",
|
||||
user.Uuid, user.Email, user.Hash)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue