changeset 257:389f234d4111

Failure to parse options should make the script exit
author Steve Kemp <steve@steve.org.uk>
date Wed, 18 Jun 2008 21:58:16 +0100
parents 5ea9f2d8bd8e
children 95cb012ad9f2
files bin/chronicle bin/chronicle-rss-importer bin/chronicle-spooler
diffstat 3 files changed, 78 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/bin/chronicle	Tue Jun 03 21:48:39 2008 +0100
+++ b/bin/chronicle	Wed Jun 18 21:58:16 2008 +0100
@@ -514,50 +514,55 @@
     #
     #  Parse options.
     #
-    GetOptions(
-
-        # Help options
-        "help",        \$HELP,
-        "manual",      \$MANUAL,
-        "verbose",     \$CONFIG{ 'verbose' },
-        "version",     \$VERSION,
-        "list-themes", \$CONFIG{ 'list-themes' },
-
-        # paths
-        "comments=s",  \$CONFIG{ 'comments' },
-        "config=s",    \$CONFIG{ 'config' },
-        "input=s",     \$CONFIG{ 'input' },
-        "output=s",    \$CONFIG{ 'output' },
-        "theme-dir=s", \$CONFIG{ 'theme-dir' },
-        "theme=s",     \$CONFIG{ 'theme' },
-        "pattern=s",   \$CONFIG{ 'pattern' },
-
-        # optional
-        "force",          \$CONFIG{ 'force' },
-        "no-tags",        \$CONFIG{ 'no-tags' },
-        "no-cache",       \$CONFIG{ 'no-cache' },
-        "no-calendar",    \$CONFIG{ 'no-calendar' },
-        "no-comments",    \$CONFIG{ 'no-comments' },
-        "no-archive",     \$CONFIG{ 'no-archive' },
-        "lower-case",     \$CONFIG{ 'lower-case' },
-        "comment-days=s", \$CONFIG{ 'comment-days' },
-
-        # input format.
-        "format=s", \$CONFIG{ 'format' },
-
-        # prefix
-        "url-prefix=s", \$CONFIG{ 'url_prefix' },
-
-        # commands
-        "pre-build=s",  \$CONFIG{ 'pre-build' },
-        "post-build=s", \$CONFIG{ 'post-build' },
-
-        # title
-        "blog-title=s",    \$CONFIG{ 'blog_title' },
-        "blog-subtitle=s", \$CONFIG{ 'blog_subtitle' },
-
-
-    );
+    if (
+        !GetOptions(
+
+            # Help options
+            "help",        \$HELP,
+            "manual",      \$MANUAL,
+            "verbose",     \$CONFIG{ 'verbose' },
+            "version",     \$VERSION,
+            "list-themes", \$CONFIG{ 'list-themes' },
+
+            # paths
+            "comments=s",  \$CONFIG{ 'comments' },
+            "config=s",    \$CONFIG{ 'config' },
+            "input=s",     \$CONFIG{ 'input' },
+            "output=s",    \$CONFIG{ 'output' },
+            "theme-dir=s", \$CONFIG{ 'theme-dir' },
+            "theme=s",     \$CONFIG{ 'theme' },
+            "pattern=s",   \$CONFIG{ 'pattern' },
+
+            # optional
+            "force",          \$CONFIG{ 'force' },
+            "no-tags",        \$CONFIG{ 'no-tags' },
+            "no-cache",       \$CONFIG{ 'no-cache' },
+            "no-calendar",    \$CONFIG{ 'no-calendar' },
+            "no-comments",    \$CONFIG{ 'no-comments' },
+            "no-archive",     \$CONFIG{ 'no-archive' },
+            "lower-case",     \$CONFIG{ 'lower-case' },
+            "comment-days=s", \$CONFIG{ 'comment-days' },
+
+            # input format.
+            "format=s", \$CONFIG{ 'format' },
+
+            # prefix
+            "url-prefix=s", \$CONFIG{ 'url_prefix' },
+
+            # commands
+            "pre-build=s",  \$CONFIG{ 'pre-build' },
+            "post-build=s", \$CONFIG{ 'post-build' },
+
+            # title
+            "blog-title=s",    \$CONFIG{ 'blog_title' },
+            "blog-subtitle=s", \$CONFIG{ 'blog_subtitle' },
+
+
+        )
+      )
+    {
+        exit;
+    }
 
     pod2usage(1) if $HELP;
     pod2usage( -verbose => 2 ) if $MANUAL;
--- a/bin/chronicle-rss-importer	Tue Jun 03 21:48:39 2008 +0100
+++ b/bin/chronicle-rss-importer	Wed Jun 18 21:58:16 2008 +0100
@@ -62,13 +62,17 @@
 
 sub parseCommandLineArguments
 {
-    GetOptions(
+    if (
+        !GetOptions(
 
-        # Help options
-        "feed=s",     \$CONFIG{ 'feed' },
-        "output=s",   \$CONFIG{ 'output' },
-        "sequential", \$CONFIG{ 'sequential' },
-    );
+                     "feed=s",     \$CONFIG{ 'feed' },
+                     "output=s",   \$CONFIG{ 'output' },
+                     "sequential", \$CONFIG{ 'sequential' },
+        )
+      )
+    {
+        exit;
+    }
 }
 
 
--- a/bin/chronicle-spooler	Tue Jun 03 21:48:39 2008 +0100
+++ b/bin/chronicle-spooler	Wed Jun 18 21:58:16 2008 +0100
@@ -204,25 +204,30 @@
     #
     #  Parse options.
     #
-    GetOptions(
+    if (
+        !GetOptions(
 
-        # input / output
-        "spool-dir=s", \$CONFIG{ 'spool-dir' },
-        "live-dir=s",  \$CONFIG{ 'live-dir' },
+            # input / output
+            "spool-dir=s", \$CONFIG{ 'spool-dir' },
+            "live-dir=s",  \$CONFIG{ 'live-dir' },
 
-        # testing?
-        "test", \$CONFIG{ 'test' },
+            # testing?
+            "test", \$CONFIG{ 'test' },
 
-        # command?
-        "post-move=s", \$CONFIG{ 'post-move' },
+            # command?
+            "post-move=s", \$CONFIG{ 'post-move' },
 
-        # Help options
-        "help",    \$HELP,
-        "manual",  \$MANUAL,
-        "verbose", \$CONFIG{ 'verbose' },
-        "version", \$VERSION,
+            # Help options
+            "help",    \$HELP,
+            "manual",  \$MANUAL,
+            "verbose", \$CONFIG{ 'verbose' },
+            "version", \$VERSION,
 
-    );
+        )
+      )
+    {
+        exit;
+    }
 
     pod2usage(1) if $HELP;
     pod2usage( -verbose => 2 ) if $MANUAL;