Runs the command for all users and databases. @param offset offset for users and optional databases (offset + 1) @param optional indicates if user/database argument is optional @return success flag
(final int offset, final boolean optional)
| 37 | * @return success flag |
| 38 | */ |
| 39 | final boolean run(final int offset, final boolean optional) { |
| 40 | final String name = args[offset]; |
| 41 | final String db = offset + 1 < args.length ? args[offset + 1] : ""; |
| 42 | |
| 43 | if(!Databases.validPattern(name)) return error(NAME_INVALID_X, name); |
| 44 | if(!db.isEmpty() && !Databases.validPattern(db)) |
| 45 | return error(NAME_INVALID_X, db); |
| 46 | |
| 47 | // retrieve all users; stop if no user is found |
| 48 | final String[] users = context.users.find(Databases.regex(name)); |
| 49 | if(users.length == 0) return info(UNKNOWN_USER_X, name) && optional; |
| 50 | |
| 51 | // loop through all users |
| 52 | boolean ok = true; |
| 53 | for(final String user : users) { |
| 54 | ok &= run(user, db); |
| 55 | } |
| 56 | context.users.write(); |
| 57 | return ok; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Runs the command for the specified user and database pattern. |