| 40 | } |
| 41 | |
| 42 | func userCreateCmd(args []string) { |
| 43 | fs := setupFlagSet("create", "dnote-server user create") |
| 44 | |
| 45 | email := fs.String("email", "", "User email address (required)") |
| 46 | password := fs.String("password", "", "User password (required)") |
| 47 | dbPath := fs.String("dbPath", "", "Path to SQLite database file (env: DBPath, default: $XDG_DATA_HOME/dnote/server.db)") |
| 48 | |
| 49 | fs.Parse(args) |
| 50 | |
| 51 | requireString(fs, *email, "email") |
| 52 | requireString(fs, *password, "password") |
| 53 | |
| 54 | a, cleanup := createApp(fs, *dbPath) |
| 55 | defer cleanup() |
| 56 | |
| 57 | _, err := a.CreateUser(*email, *password, *password) |
| 58 | if err != nil { |
| 59 | log.ErrorWrap(err, "creating user") |
| 60 | os.Exit(1) |
| 61 | } |
| 62 | |
| 63 | fmt.Printf("User created successfully\n") |
| 64 | fmt.Printf("Email: %s\n", *email) |
| 65 | } |
| 66 | |
| 67 | func userRemoveCmd(args []string, stdin io.Reader) { |
| 68 | fs := setupFlagSet("remove", "dnote-server user remove") |