Index: trunk/psphot/src/psphotParseCamera.c
===================================================================
--- trunk/psphot/src/psphotParseCamera.c	(revision 6117)
+++ trunk/psphot/src/psphotParseCamera.c	(revision 6311)
@@ -1,11 +1,16 @@
 # include "psphot.h"
+
+# define METADATA_ADD_DEFAULT(CONFIG, TYPE, NAME, VALUE, COMMENT)\
+    { psMetadataItem *ITEM; \
+      ITEM = psMetadataLookup (CONFIG, NAME); \
+      if (ITEM == NULL) { \
+	psMetadataAdd##TYPE (CONFIG, PS_LIST_TAIL, NAME, 0, COMMENT, VALUE); \
+      } else { psFree (ITEM); } }
 
 ppFile *psphotParseCamera (ppConfig *config) {
 
-    bool status;
-
     ppFile *input = ppFileAlloc ();
 
-    input->filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, config->arguments, "-input"));
+    input->filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, config->arguments, "INPUT_FILE"));
 
     // Open the input image
@@ -33,8 +38,7 @@
     }
 
-    // Determine the correct recipe to use
-    // if the user specifies a recipe, no default values are supplied
+    // Determine the correct recipe to use (from camera or from user)
+    // if config->recipe is not NULL, it is a user-supplied recipe
     if (!config->recipe) {
-
 	config->recipe = pmConfigRecipeFromCamera(config->camera, PSPHOT_RECIPE);
 	if (config->recipe == NULL) {
@@ -43,9 +47,8 @@
 	}
     }
-    
-    // recipe override values:
-    psMetadata *recipe = psMetadataLookupPtr (&status, config->arguments, "RECIPE.OPTIONS");
+
+    // recipe override values (command-line options):
     psMetadataItem *item = NULL;
-    psMetadataIterator *iter = psMetadataIteratorAlloc (recipe, PS_LIST_HEAD, NULL);
+    psMetadataIterator *iter = psMetadataIteratorAlloc (config->options, PS_LIST_HEAD, NULL);
     while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
 	psMetadataAddItem (config->recipe, item, PS_LIST_TAIL, PS_META_REPLACE);
@@ -54,17 +57,33 @@
     psFree (iter);
 
-    psMetadataAddStr (config->recipe, PS_LIST_TAIL, "FITMODE", 0, "", "NONE");
-    psMetadataAddStr (config->recipe, PS_LIST_TAIL, "PHOTCODE", 0, "", "NONE");
-    psMetadataAddStr (config->recipe, PS_LIST_TAIL, "BREAK_POINT", 0, "", "NONE");
+    // set default recipe values here
+    METADATA_ADD_DEFAULT (config->recipe, Str, "FITMODE", "NONE", "");
+    METADATA_ADD_DEFAULT (config->recipe, Str, "PHOTCODE", "NONE", "");
+    METADATA_ADD_DEFAULT (config->recipe, Str, "BREAK_POINT", "NONE", "");
+    METADATA_ADD_DEFAULT (config->recipe, Str, "OUTPUT_FORMAT", "CMP", "");
+    METADATA_ADD_DEFAULT (config->recipe, Str, "OUTPUT_MODE", "SPLIT", "");
 
-    // XXX EAM : extend this to allow an array of selected chips by name
     // Chip selection: if we are using a single chip, select it for each FPA
-    int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on
-    if (chipNum >= 0) {
-        if (! pmFPASelectChip(input->fpa, chipNum)) {
-            psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
-            exit(EXIT_FAILURE);
+    // Chip numbers to work on: -chip 1,2,3,5,8,10
+    char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 
+    if (chips != NULL) {
+	char *p = chips;
+	while (strlen(p)) {
+	    char *q = strchr (p, ',');
+	    if (q == NULL) { 
+		q = p + strlen(p);
+	    } else {
+		*q = 0;
+		q = q + 1;
+	    }
+	    int chipNum = atoi(p);
+	    // XXX EAM : extend this to allow an array of selected chips (by name)
+	    if (! pmFPASelectChip(input->fpa, chipNum)) {
+		psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
+		exit(EXIT_FAILURE);
+	    }
+	    psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
+	    p = q;
         }
-        psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
     }
 
@@ -72,4 +91,5 @@
     input->fpa = pmFPAConstruct(config->camera);
 
+    psTrace(__func__, 1, "Done with psphotParseCamera...\n");
     return input;
 }
