]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/commandline.inc
Ticket #2913: Realtime background update marker no longer triggers false positives...
[quix0rs-gnu-social.git] / scripts / commandline.inc
index a29f588448db88f7d048be2d5475ebe9f786874e..9390890ef33c0f7379c38d58fee4325aefdd935e 100644 (file)
@@ -178,6 +178,10 @@ function get_option_value($opt, $alt=null)
     return null;
 }
 
+class NoUserArgumentException extends Exception
+{
+}
+
 function getUser()
 {
     $user = null;
@@ -195,9 +199,48 @@ function getUser()
             throw new Exception("Can't find user with nickname '$nickname'");
         }
     } else {
-        show_help();
-        exit(1);
+        throw new NoUserArgumentException("No user argument specified.");
     }
 
     return $user;
 }
+
+/** "Printf not quiet" */
+
+function printfnq()
+{
+    if (have_option('q', 'quiet')) {
+        return null;
+    }
+
+    $cargs  = func_num_args();
+
+    if ($cargs == 0) {
+        return 0;
+    }
+
+    $args   = func_get_args();
+    $format = array_shift($args);
+
+    return vprintf($format, $args);
+}
+
+/** "Print when verbose" */
+
+function printfv()
+{
+    if (!have_option('v', 'verbose')) {
+        return null;
+    }
+
+    $cargs  = func_num_args();
+
+    if ($cargs == 0) {
+        return 0;
+    }
+
+    $args   = func_get_args();
+    $format = array_shift($args);
+
+    return vprintf($format, $args);
+}
\ No newline at end of file