(args []string)
| 173 | } |
| 174 | |
| 175 | func userCmd(args []string) { |
| 176 | if len(args) < 1 { |
| 177 | fmt.Println(`Usage: |
| 178 | dnote-server user [command] |
| 179 | |
| 180 | Available commands: |
| 181 | create: Create a new user |
| 182 | list: List all users |
| 183 | remove: Remove a user |
| 184 | reset-password: Reset a user's password`) |
| 185 | os.Exit(1) |
| 186 | } |
| 187 | |
| 188 | subcommand := args[0] |
| 189 | subArgs := []string{} |
| 190 | if len(args) > 1 { |
| 191 | subArgs = args[1:] |
| 192 | } |
| 193 | |
| 194 | switch subcommand { |
| 195 | case "create": |
| 196 | userCreateCmd(subArgs) |
| 197 | case "list": |
| 198 | userListCmd(subArgs, os.Stdout) |
| 199 | case "remove": |
| 200 | userRemoveCmd(subArgs, os.Stdin) |
| 201 | case "reset-password": |
| 202 | userResetPasswordCmd(subArgs) |
| 203 | default: |
| 204 | fmt.Printf("Unknown subcommand: %s\n\n", subcommand) |
| 205 | fmt.Println(`Available commands: |
| 206 | create: Create a new user |
| 207 | list: List all users |
| 208 | remove: Remove a user (only if they have no notes or books) |
| 209 | reset-password: Reset a user's password`) |
| 210 | os.Exit(1) |
| 211 | } |
| 212 | } |
no test coverage detected