Index: trunk/ppMerge/src/ppMergeConfig.c
===================================================================
--- trunk/ppMerge/src/ppMergeConfig.c	(revision 6824)
+++ trunk/ppMerge/src/ppMergeConfig.c	(revision 6998)
@@ -1,31 +1,52 @@
-# include "ppMerge.h"
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
 
-static void usage (void) {
-    fprintf (stderr, "USAGE: ppMerge [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
-    exit (2);
+#include "ppMergeConfig.h"
+
+// Output usage information
+static void usage(const char *programName // Name of the program
+    )
+{
+    printf("Merge multiple calibration frames into a master frame by stacking.\n\n"
+           "Usage:\n"
+           "\t%s OUTPUT.fits [-files FILES] [-list FILE_LIST]\n\n"
+           "where:\n"
+           "FILES       is a glob to be interpreted by the program.\n"
+           "FILE_LIST   is a list of files (including a glob interpreted by the shell).\n"
+           "\n", programName);
+    exit(EXIT_FAILURE);
 }
 
-pmConfig *ppMergeConfig (int argc, char **argv)
+pmConfig *ppMergeConfig(int *argc, char **argv)
 {
-    bool status;
+    if (*argc == 1) {
+        usage(argv[0]);
+    }
 
-    if (argc == 1) usage ();
-
-    // load the site-wide configuration information
-    pmConfig *config = pmConfigRead(&argc, argv);
+    // Load the site-wide configuration information
+    pmConfig *config = pmConfigRead(argc, argv);
     if (! config) {
         psErrorStackPrint(stderr, "Can't find site configuration!\n");
-        exit(EXIT_FAILURE);
+        usage(argv[0]);
     }
 
-    // Parse other command-line arguments
+    // Parse other command-line arguments, save for future use
     config->arguments = psMetadataAlloc(); // The arguments, with default values
+    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-type", 0, "Type of calibration frame", "");
+    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "-zero", 0, "Subtract background?", false);
+    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "-scale", 0, "Scale by background?", false);
+    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "-exptime", 0, "Scale by the exposure time?", false);
+    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-onoff", 0, "Number of on/off pairs", 0);
 
-    // the input file is a required argument; if not found, we will exit
-    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
-    if (!status) { usage ();}
+    // We require an input file set
+    bool status = pmConfigFileSetsMD(config->arguments, argc, argv, "INPUT", "-files", "-list");
+    if (!status) {
+        usage(argv[0]);
+    }
 
-    if (! psArgumentParse(config->arguments, &argc, argv) || argc != 2) {
-	usage ();
+    // Parse other arguments
+    if (! psArgumentParse(config->arguments, argc, argv) || *argc != 2) {
+        usage(argv[0]);
     }
 
@@ -33,21 +54,17 @@
     psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
 
-    // the input image(s) are required arguments
-    // the first one defines the camera
+    // The input images are required.  The first one defines the camera.
     status = false;
-    pmFPAfileFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT");
+    pmFPAfileFromArgs(&status, config, "PPMERGE.INPUT", "INPUT");
     if (!status) {
-	psAbort (__func__, "missing INPUT entry");
+        usage(argv[0]);
     }
 
-# if 0
-    // define Database handle, if used
+
+#if 0
+    // Define database handle, if required
     config->database = pmConfigDB(config->site);
-# endif
+#endif
 
-    return true;
-} 
-
-/* we require all information needed to determine the scaling 
-   to be written in the header.  is this reasonable? 
-*/
+    return config;
+}
