listAccounts command
This commit is contained in:
parent
be5cd05d08
commit
5e493554dc
6 changed files with 50 additions and 9 deletions
27
main.go
27
main.go
|
@ -98,6 +98,27 @@ func main() {
|
|||
fmt.Printf("Invites deleted successfully.\n")
|
||||
return
|
||||
|
||||
case "listAccounts":
|
||||
accounts, err := controller.GetAllAccounts(global.DB)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch accounts: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, account := range accounts {
|
||||
fmt.Printf(
|
||||
"User: %s\n" +
|
||||
"\tID: %s\n" +
|
||||
"\tEmail: %s\n" +
|
||||
"\tCreated: %s\n",
|
||||
account.Username,
|
||||
account.ID,
|
||||
account.Email,
|
||||
account.CreatedAt,
|
||||
)
|
||||
}
|
||||
return
|
||||
|
||||
case "deleteAccount":
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintf(os.Stderr, "FATAL: Account name not specified for -deleteAccount\n")
|
||||
|
@ -108,7 +129,7 @@ func main() {
|
|||
|
||||
account, err := controller.GetAccount(global.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %s\n", username, err.Error())
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
@ -135,10 +156,12 @@ func main() {
|
|||
|
||||
}
|
||||
|
||||
fmt.Printf(
|
||||
// command help
|
||||
fmt.Print(
|
||||
"Available commands:\n\n" +
|
||||
"createInvite:\n\tCreates an invite code to register new accounts.\n" +
|
||||
"purgeInvites:\n\tDeletes all available invite codes.\n" +
|
||||
"listAccounts:\n\tLists all active accounts.\n",
|
||||
"deleteAccount <username>:\n\tDeletes an account with a given `username`.\n",
|
||||
)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue