summaryrefslogtreecommitdiff
path: root/scripts/commandline.inc
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-15 16:00:00 -0400
committerEvan Prodromou <evan@status.net>2010-09-15 16:00:00 -0400
commitdffec9f223c1e45832d274c34f7bd6624cbf87ea (patch)
tree788136a386e37fd5fc956187f4f581ce8853f1ed /scripts/commandline.inc
parentb2abae433de8ae625fc0420eb78ee74479f6e9b9 (diff)
move getUser() function to commandline.inc
Diffstat (limited to 'scripts/commandline.inc')
-rw-r--r--scripts/commandline.inc24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/commandline.inc b/scripts/commandline.inc
index a475e11d0..a29f58844 100644
--- a/scripts/commandline.inc
+++ b/scripts/commandline.inc
@@ -177,3 +177,27 @@ function get_option_value($opt, $alt=null)
return null;
}
+
+function getUser()
+{
+ $user = null;
+
+ if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+ $user = User::staticGet('id', $id);
+ if (empty($user)) {
+ throw new Exception("Can't find user with id '$id'.");
+ }
+ } else if (have_option('n', 'nickname')) {
+ $nickname = get_option_value('n', 'nickname');
+ $user = User::staticGet('nickname', $nickname);
+ if (empty($user)) {
+ throw new Exception("Can't find user with nickname '$nickname'");
+ }
+ } else {
+ show_help();
+ exit(1);
+ }
+
+ return $user;
+}