- /* Mimic the message from libxml.c::php_libxml_ctx_error_level() */
- private function log_xml_error($error) {
- $output = "";
-
- switch ($error->level) {
- case LIBXML_ERR_WARNING:
- $output .= "Warning $error->code: ";
- break;
- case LIBXML_ERR_ERROR:
- $output .= "Error $error->code: ";
- break;
- case LIBXML_ERR_FATAL:
- $output .= "Fatal Error $error->code: ";
- break;
- }
-
- $output .= trim($error->message);
-
- if ($error->file) {
- $output .= " in $error->file";
- } else {
- $output .= " in Entity,";
+ $cli_options = getopt("em:u:v:h", ["help"]);
+ foreach ($cli_options as $opt => $val) {
+ switch ($opt) {
+ case 'e':
+ $options['generate_enclosure'] = TRUE;
+ break;
+
+ case 'm':
+ $ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+ if (NULL === $ret) {
+ fwrite(STDERR, "Invalid argument for the -m option.\n");
+ fwrite(STDERR, usage($argv));
+ exit(1);
+ }
+ $options['show_multimedia'] = $val;
+ break;
+
+ case 'u':
+ $ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+ if (NULL === $ret) {
+ fwrite(STDERR, "Invalid argument for the -u option.\n");
+ fwrite(STDERR, usage($argv));
+ exit(1);
+ }
+ $options['show_usernames'] = $val;
+ break;
+
+ case 'v':
+ $ret = filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+ if (NULL === $ret) {
+ fwrite(STDERR, "Invalid argument for the -v option.\n");
+ fwrite(STDERR, usage($argv));
+ exit(1);
+ }
+ $options['verbose_output'] = $val;
+ break;
+
+ case 'h':
+ case 'help':
+ echo usage($argv);
+ exit(0);
+
+ default:
+ fwrite(STDERR, usage($argv));
+ exit(1);