Index: trunk/bin/module_maker/module.cli.php
===================================================================
--- trunk/bin/module_maker/module.cli.php	(revision 534)
+++ trunk/bin/module_maker/module.cli.php	(revision 556)
@@ -36,5 +36,5 @@
 
 $op = null;
-$valid_ops = array('clean', 'var', 'test');
+$valid_ops = array('clean', 'var', 'test', 'admin', 'public');
 
 // Test for arguments.
@@ -43,29 +43,32 @@
     $module_name_plural = $_SERVER['argv'][3];
 } else {
-    die(basename($_SERVER['argv'][0]) . " Error: invalid arguments. Try like this:
-
-    " . basename($_SERVER['argv'][0]) . " site_directory name_singular name_plural [operation]
+    die(basename($_SERVER['argv'][0]) . " error: missing arguments.
+
+Usage: " . basename($_SERVER['argv'][0]) . " SITE_DIRECTORY NAME_SINGULAR NAME_PLURAL OPERATION
+
+Example: export DB_NAME=mydb; " . basename($_SERVER['argv'][0]) . " . order orders admin
 
 Valid operations include: " . join(', ', $valid_ops) . "
 
 The following files will be generated by this script:
-<site_directory>/admin/nameplural.php
-<site_directory>/admin/_templates/namesingular_list.ihtml
-<site_directory>/admin/_templates/namesingular_form.ihtml
-<site_directory>/html/nameplural.php
-<site_directory>/html/_templates/namesingular_list.ihtml
-<site_directory>/html/_templates/namesingular.ihtml
+
+âadminâ operation:
+SITE_DIRECTORY/admin/nameplural.php
+SITE_DIRECTORY/admin/_templates/namesingular_list.ihtml
+SITE_DIRECTORY/admin/_templates/namesingular_form.ihtml
+
+âpublicâ operation:
+SITE_DIRECTORY/html/nameplural.php
+SITE_DIRECTORY/html/_templates/namesingular_list.ihtml
+SITE_DIRECTORY/html/_templates/namesingular.ihtml
 
 ");
 }
 
-// Test for operation.
-if (isset($_SERVER['argv'][4])) {
-    // Optional fourth arg is op.
-    $op = $_SERVER['argv'][4];
-    // Make sure op is valid.
-    if (!in_array($op, $valid_ops)) {
-        die(basename($_SERVER['argv'][0]) . " Warning: Operation '$op' is not something I know how to do Please select one of: " . join(", ", $valid_ops) . "\n");
-    }
+// Test for valid operation.
+$op = $_SERVER['argv'][4];
+// Make sure op is valid.
+if (!in_array($op, $valid_ops)) {
+    die(basename($_SERVER['argv'][0]) . " Warning: Operation '$op' is not something I know how to do Please select one of: " . join(", ", $valid_ops) . "\n");
 }
 
@@ -74,6 +77,8 @@
     echo "RUNNING MODULE MAKER IN TEST MODE.\n\n";
     break;
-default :
-
+case 'admin' :
+case 'public' :
+    echo "Generating only $op filesâŠ\n\n";
+    break;
 }
 
@@ -134,25 +139,23 @@
 
 // Ensure skel files exist.
-if (
-    !file_exists("$skel_dir/admin.php") ||
-    !file_exists("$skel_dir/public.php") ||
-    !file_exists("$skel_dir/public.ihtml") ||
-    !file_exists("$skel_dir/public_list.ihtml")
-) {
-    die(basename($_SERVER['argv'][0]) . " Warning: one or more skeleton source files missing. Please check directory: $skel_dir.\n");
+if ('admin' == $op && (!file_exists("$skel_dir/admin.php") || !file_exists("$skel_dir/adm_list.ihtml") || !file_exists("$skel_dir/adm_form.ihtml"))) {
+    die(basename($_SERVER['argv'][0]) . " Warning: one or more admin skeleton source files missing. Please check directory: $skel_dir.\n");
+}
+if ('public' == $op && (!file_exists("$skel_dir/public.php") || !file_exists("$skel_dir/public.ihtml") || !file_exists("$skel_dir/public_list.ihtml"))) {
+    die(basename($_SERVER['argv'][0]) . " Warning: one or more public skeleton source files missing. Please check directory: $skel_dir.\n");
 }
 
 if (!isset($_SERVER['argv'][4]) || 'var' != $_SERVER['argv'][4]) {
     // Ensure essential directories exist, except for 'var' op.
-    if (!is_dir("$admin_dir")) {
+    if ('admin' == $op && !is_dir("$admin_dir")) {
         die(basename($_SERVER['argv'][0]) . " Error: admin_dir '$admin_dir' directory not found.\n");
     }
-    if (!is_dir("$admin_tpl_dir")) {
+    if ('admin' == $op && !is_dir("$admin_tpl_dir")) {
         die(basename($_SERVER['argv'][0]) . " Error: admin_tpl_dir '$admin_tpl_dir' directory not found.\n");
     }
-    if (!is_dir("$public_dir")) {
+    if ('public' == $op && !is_dir("$public_dir")) {
         die(basename($_SERVER['argv'][0]) . " Error: public_dir '$public_dir' directory not found.\n");
     }
-    if (!is_dir("$public_tpl_dir")) {
+    if ('public' == $op && !is_dir("$public_tpl_dir")) {
         die(basename($_SERVER['argv'][0]) . " Error: public_tpl_dir '$public_tpl_dir' directory not found.\n");
     }
@@ -230,10 +233,17 @@
 // -------------FILES-------------
 
-$skel_files['skel_admin_script'] = file_get_contents($skel_dir . '/admin.php');
-$skel_files['skel_admin_list_template'] = file_get_contents($skel_dir . '/adm_list.ihtml');
-$skel_files['skel_admin_form_template'] = file_get_contents($skel_dir . '/adm_form.ihtml');
-$skel_files['skel_public_script'] = file_get_contents($skel_dir . '/public.php');
-$skel_files['skel_public_list_template'] = file_get_contents($skel_dir . '/public_list.ihtml');
-$skel_files['skel_public_detail_template'] = file_get_contents($skel_dir . '/public.ihtml');
+switch ($op) {
+case 'admin':
+    $skel_files['skel_admin_script'] = file_get_contents($skel_dir . '/admin.php');
+    $skel_files['skel_admin_list_template'] = file_get_contents($skel_dir . '/adm_list.ihtml');
+    $skel_files['skel_admin_form_template'] = file_get_contents($skel_dir . '/adm_form.ihtml');
+    break;
+
+case 'public':
+    $skel_files['skel_public_script'] = file_get_contents($skel_dir . '/public.php');
+    $skel_files['skel_public_list_template'] = file_get_contents($skel_dir . '/public_list.ihtml');
+    $skel_files['skel_public_detail_template'] = file_get_contents($skel_dir . '/public.ihtml');
+    break;
+}
 
 
@@ -495,76 +505,80 @@
  *****************************************************************************/
 
-// (1) Admin script.
-if (file_exists("$admin_dir/$admin_script")) {
-    echo "Admin script already exists: $admin_dir/$admin_script\n";
-} else {
-    echo "Writing admin script: $admin_dir/$admin_script\n";
-    if ('test' != $op) {
-        $fp = fopen("$admin_dir/$admin_script", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_script']));
-        fclose($fp);
-    }
-}
-
-// (2) Admin list template.
-if (file_exists("$admin_tpl_dir/$admin_list_template")) {
-    echo "Admin list template already exists: $admin_tpl_dir/$admin_list_template\n";
-} else {
-    echo "Writing admin list template: $admin_tpl_dir/$admin_list_template\n";
-    if ('test' != $op) {
-        $fp = fopen("$admin_tpl_dir/$admin_list_template", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_list_template']));
-        fclose($fp);
-    }
-}
-
-// (3) Admin form template.
-if (file_exists("$admin_tpl_dir/$admin_form_template")) {
-    echo "Admin form template already exists: $admin_tpl_dir/$admin_form_template\n";
-} else {
-    echo "Writing admin form template: $admin_tpl_dir/$admin_form_template\n";
-    if ('test' != $op) {
-        $fp = fopen("$admin_tpl_dir/$admin_form_template", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_form_template']));
-        fclose($fp);
-    }
-}
-
-// (4) Public script.
-if (file_exists("$public_dir/$public_script")) {
-    echo "Public script already exists: $public_dir/$public_script\n";
-} else {
-    echo "Writing public script: $public_dir/$public_script\n";
-    if ('test' != $op) {
-        $fp = fopen("$public_dir/$public_script", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_script']));
-        fclose($fp);
-    }
-}
-
-// (5) Public list template.
-if (file_exists("$public_tpl_dir/$public_list_template")) {
-    echo "Public list template already exists: $public_tpl_dir/$public_list_template\n";
-} else {
-    echo "Writing public list template: $public_tpl_dir/$public_list_template\n";
-    if ('test' != $op) {
-        $fp = fopen("$public_tpl_dir/$public_list_template", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_list_template']));
-        fclose($fp);
-    }
-}
-
-// (6) Public detail template.
-if (file_exists("$public_tpl_dir/$public_detail_template")) {
-    echo "Public detail template already exists: $public_tpl_dir/$public_detail_template\n";
-} else {
-    echo "Writing public detail template: $public_tpl_dir/$public_detail_template\n";
-    if ('test' != $op) {
-        $fp = fopen("$public_tpl_dir/$public_detail_template", "w");
-        fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_detail_template']));
-        fclose($fp);
-    }
-}
-
+if ('admin' == $op) {
+    // (1) Admin script.
+    if (file_exists("$admin_dir/$admin_script")) {
+        echo "Admin script already exists: $admin_dir/$admin_script\n";
+    } else {
+        echo "Writing admin script: $admin_dir/$admin_script\n";
+        if ('test' != $op) {
+            $fp = fopen("$admin_dir/$admin_script", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_script']));
+            fclose($fp);
+        }
+    }
+
+    // (2) Admin list template.
+    if (file_exists("$admin_tpl_dir/$admin_list_template")) {
+        echo "Admin list template already exists: $admin_tpl_dir/$admin_list_template\n";
+    } else {
+        echo "Writing admin list template: $admin_tpl_dir/$admin_list_template\n";
+        if ('test' != $op) {
+            $fp = fopen("$admin_tpl_dir/$admin_list_template", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_list_template']));
+            fclose($fp);
+        }
+    }
+
+    // (3) Admin form template.
+    if (file_exists("$admin_tpl_dir/$admin_form_template")) {
+        echo "Admin form template already exists: $admin_tpl_dir/$admin_form_template\n";
+    } else {
+        echo "Writing admin form template: $admin_tpl_dir/$admin_form_template\n";
+        if ('test' != $op) {
+            $fp = fopen("$admin_tpl_dir/$admin_form_template", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_form_template']));
+            fclose($fp);
+        }
+    }
+}
+
+if ('public' == $op) {
+    // (4) Public script.
+    if (file_exists("$public_dir/$public_script")) {
+        echo "Public script already exists: $public_dir/$public_script\n";
+    } else {
+        echo "Writing public script: $public_dir/$public_script\n";
+        if ('test' != $op) {
+            $fp = fopen("$public_dir/$public_script", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_script']));
+            fclose($fp);
+        }
+    }
+
+    // (5) Public list template.
+    if (file_exists("$public_tpl_dir/$public_list_template")) {
+        echo "Public list template already exists: $public_tpl_dir/$public_list_template\n";
+    } else {
+        echo "Writing public list template: $public_tpl_dir/$public_list_template\n";
+        if ('test' != $op) {
+            $fp = fopen("$public_tpl_dir/$public_list_template", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_list_template']));
+            fclose($fp);
+        }
+    }
+
+    // (6) Public detail template.
+    if (file_exists("$public_tpl_dir/$public_detail_template")) {
+        echo "Public detail template already exists: $public_tpl_dir/$public_detail_template\n";
+    } else {
+        echo "Writing public detail template: $public_tpl_dir/$public_detail_template\n";
+        if ('test' != $op) {
+            $fp = fopen("$public_tpl_dir/$public_detail_template", "w");
+            fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_detail_template']));
+            fclose($fp);
+        }
+    }
+
+}
 echo "Done!\n";
 
