Index: /branches/end_stage/ippTools/src/caltool.c
===================================================================
--- /branches/end_stage/ippTools/src/caltool.c	(revision 16105)
+++ /branches/end_stage/ippTools/src/caltool.c	(revision 16106)
@@ -85,15 +85,6 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // required options
-    bool status = false;
-    psString dvodb = psMetadataLookupStr(&status, config->args, "-dvodb");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dvodb");
-        return false;
-    }
-    if (!dvodb) {
-        psError(PS_ERR_UNKNOWN, true, "-dvodb is required");
-        return false;
-    }
+    // required 
+    PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", true, false);
 
     if (!calDBInsert(config->dbh,
@@ -115,10 +106,6 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    bool status = false;
-    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
-    if (!status) {
-        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
-        return false;
-    }
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
 
     psString query = psStringCopy("SELECT * FROM calDB");
@@ -164,14 +151,4 @@
     }
 
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
     if (psArrayLength(output)) {
         if (!convertIdToStr(output)) {
@@ -199,45 +176,9 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // required options
-    bool status = false;
-    psString cal_id = psMetadataLookupStr(&status, config->args, "-cal_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cal_id");
-        return false;
-    }
-    if (!cal_id) {
-        psError(PS_ERR_UNKNOWN, true, "-cal_id is required");
-        return false;
-    }
-
-    psString region = psMetadataLookupStr(&status, config->args, "-region");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -region");
-        return false;
-    }
-    if (!region) {
-        psError(PS_ERR_UNKNOWN, true, "-region is required");
-        return false;
-    }
-
-    psString last_step = psMetadataLookupStr(&status, config->args, "-last_step");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -last_step");
-        return false;
-    }
-    if (!last_step) {
-        psError(PS_ERR_UNKNOWN, true, "-last_step is required");
-        return false;
-    }
-
-    psString state = psMetadataLookupStr(&status, config->args, "-state");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
-        return false;
-    }
-    if (!state) {
-        psError(PS_ERR_UNKNOWN, true, "-state is required");
-        return false;
-    }
+    // required
+    PXOPT_LOOKUP_STR(cal_id, config->args, "-cal_id", true, false);
+    PXOPT_LOOKUP_STR(region, config->args, "-region", true, false);
+    PXOPT_LOOKUP_STR(last_step, config->args, "-last_step", true, false);
+    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
 
     if (!calRunInsert(config->dbh,
@@ -260,10 +201,6 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    bool status = false;
-    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
-    if (!status) {
-        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
-        return false;
-    }
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
 
     psString query = psStringCopy("SELECT * FROM calRun");
@@ -309,14 +246,4 @@
     }
 
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
     if (psArrayLength(output)) {
         if (!convertIdToStr(output)) {
