/**
  * Determines what action should be performed and takes that action.
  *
  * @uses MpmDbHelper::test()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * @uses MpmCommandLineWriter::writeHeader()
  * @uses MpmCommandLineWriter::writeFooter()
  * @uses MpmBuildController::build()
  * @uses MPM_DB_PATH
  *
  * @return void
  */
 public function doAction()
 {
     // make sure system is init'ed
     MpmDbHelper::test();
     $this->clw = MpmCommandLineWriter::getInstance();
     $with_data = $forced = $dryrun = false;
     // are we adding a schema file?
     if (isset($this->arguments[0])) {
         if ($this->arguments[0] == 'add') {
             $this->add();
             // stop here
             exit;
         } else {
             if ($this->arguments[0] == 'with_data') {
                 $with_data = true;
                 // remove the first 'with_data'
                 array_shift($this->arguments);
             }
         }
     }
     // parse other optional arguments
     list($forced, $dryrun) = $this->parse_options($this->arguments);
     // make sure the schema file exists
     if (!file_exists(MPM_DB_PATH . 'schema.php')) {
         $this->clw->addText('The schema file does not exist.  Run this command with the "add" argument to create one (only a stub).');
         $this->clw->write();
         exit;
     }
     // make sure the test data file exists
     if ($with_data == true && !file_exists(MPM_DB_PATH . 'test_data.php')) {
         $this->clw->addText('The test data file does not exist.  Run this command with the "add" argument to create one (only a stub).');
         $this->clw->write();
         exit;
     }
     $this->clw->writeHeader();
     if (!$forced && !$dryrun) {
         echo "\nWARNING:  IF YOU CONTINUE, ALL TABLES IN YOUR DATABASE WILL BE ERASED!";
         echo "\nDO YOU WANT TO CONTINUE? [y/N] ";
         $answer = fgets(STDIN);
         $answer = trim($answer);
         $answer = strtolower($answer);
         if (empty($answer) || substr($answer, 0, 1) == 'n') {
             echo "\nABORTED!\n\n";
             $this->clw->writeFooter();
             exit;
         }
     }
     echo "\n";
     $this->build($with_data);
     $this->clw->writeFooter();
     exit;
 }