mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 01:06:45 +08:00
organized files
This commit is contained in:
1 parent
d5f6dc6fa0
commit
2e8eceb1e2
9 files changed
+116
-86
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package createcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var createAccountCmd = &cobra.Command{
|
||||
Use: "account [username] [email] [classicToken]",
|
||||
Short: "Create or update an account",
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
account := utils.Account{
|
||||
Username: args[0],
|
||||
Email: args[1],
|
||||
ClassicToken: args[2],
|
||||
}
|
||||
if strings.TrimSpace(account.Username) == "" || strings.TrimSpace(account.Email) == "" || strings.TrimSpace(account.ClassicToken) == "" {
|
||||
return fmt.Errorf("username, email, and classicToken are required")
|
||||
}
|
||||
|
||||
if err := utils.UpsertAccount(account); err != nil { return err }
|
||||
|
||||
fmt.Printf("Saved account: %s\n", account.Username)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user