public function do_actions()
 {
     $module_directory = HaddockProjectOrganisation_ModuleDirectoriesHelper::get_module_directory_from_cli_choice();
     echo 'Creating an input validator for the ' . $module_directory->get_title() . ' module.' . PHP_EOL;
     $new_input_validator_name = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the name of the input validator: ', new InputValidation_InputValidatorNameValidator());
     InputValidation_InputValidatorsHelper::create_input_validator($new_input_validator_name, $module_directory);
 }
 public function do_actions()
 {
     $module_directory = HaddockProjectOrganisation_ModuleDirectoriesHelper::get_module_directory_from_cli_choice();
     echo 'Creating a file class for the ' . $module_directory->get_title() . ' module.' . PHP_EOL;
     $new_file_class_name = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the name of the file class: ', new FileSystem_FileClassNameValidator());
     FileSystem_FileClassesHelper::create_file_class($new_file_class_name, $module_directory);
 }
 public function do_actions()
 {
     $module_directory = HaddockProjectOrganisation_ModuleDirectoriesHelper::get_module_directory_from_cli_choice();
     echo 'Setting the camel case root for the ' . $module_directory->get_title() . ' module.' . PHP_EOL;
     $camel_case_root = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the upper camel case root: ', new HaddockProjectOrganisation_ModuleDirectoryCamelCaseRootValidator());
     HaddockProjectOrganisation_ModuleDirectoriesCamelCaseRootsHelper::set_camel_case_root($camel_case_root, $module_directory);
 }
 public function do_actions()
 {
     if ($this->has_arg('datum-name')) {
         $datum_name = $this->get_arg('datum-name');
     } else {
         echo 'Which datum do you want to set?' . PHP_EOL;
         $datum_name = CLIScripts_UserInterrogationHelper::get_choice_from_string_array(array('Name', 'Title', 'Copyright Holder', 'Version Code', 'Camel Case Root'));
         echo "Setting the '{$datum_name}'" . PHP_EOL;
     }
     if ($this->has_arg('new-value')) {
         $new_value = $this->get_arg('new-value');
     } else {
         echo 'Please enter the new value:' . PHP_EOL;
         $new_value = trim(fgets(STDIN));
         echo 'New value: ' . $new_value . PHP_EOL;
     }
     switch ($datum_name) {
         case 'Name':
             HaddockProjectOrganisation_ProjectInformationHelper::set_name($new_value);
             break;
         case 'Title':
             HaddockProjectOrganisation_ProjectInformationHelper::set_title($new_value);
             break;
         case 'Copyright Holder':
             HaddockProjectOrganisation_ProjectInformationHelper::set_copyright_holder($new_value);
             break;
         case 'Version Code':
             HaddockProjectOrganisation_ProjectInformationHelper::set_version_code($new_value);
             break;
         case 'Camel Case Root':
             HaddockProjectOrganisation_ProjectInformationHelper::set_camel_case_root($new_value);
             break;
     }
 }
 private function get_host()
 {
     if ($this->has_arg('host')) {
         return $this->get_arg('host');
     } else {
         return CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the host name:' . PHP_EOL, new Database_HostNameValidator());
     }
 }
 private function get_default_location()
 {
     if ($this->has_arg('default-location')) {
         return $this->get_arg('default-location');
     } else {
         return CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the default location:' . PHP_EOL, new PublicHTML_DefaultLocationValidator());
     }
 }
 private function get_server_address()
 {
     if ($this->has_arg('server-address')) {
         return $this->get_arg('server-address');
     } else {
         return CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the server-address:' . PHP_EOL, new PublicHTML_ServerAddressValidator());
     }
 }
 public function do_actions()
 {
     /*
      * Get the module directory.
      */
     $module_directory = HaddockProjectOrganisation_ModuleDirectoriesHelper::get_module_directory_from_cli_choice();
     echo 'Creating a CLI script for the ' . $module_directory->get_title() . ' module.' . PHP_EOL;
     $new_script_name = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the name of the script: ', new CLIScripts_NewScriptNameValidator());
     CLIScripts_CLIScriptsHelper::create_cli_script($new_script_name, $module_directory);
 }
 private function get_remote_server()
 {
     if ($this->has_arg('remote-server')) {
         return $this->get_arg('remote-server');
     } else {
         $remote_servers = ServerAdminScripts_MySQLDumpsDownloadingHelper::get_remote_servers();
         if (count($remote_servers) > 0) {
             echo 'Please choose the server address to delete:' . PHP_EOL;
             return CLIScripts_UserInterrogationHelper::get_choice_from_string_array($remote_servers);
         }
     }
 }
 public static function get_module_directory_from_cli_choice()
 {
     $module_directories = self::get_all_module_directories();
     usort($module_directories, create_function('$a, $b', 'return strcmp($a->get_identifying_name(), $b->get_identifying_name());'));
     $mds = array();
     $first = TRUE;
     foreach ($module_directories as $module_directory) {
         $name = $module_directory->get_identifying_name();
         $mds[$name] = $module_directory;
     }
     $chosen_module_name = CLIScripts_UserInterrogationHelper::get_choice_from_string_array(array_keys($mds));
     return $mds[$chosen_module_name];
 }
 /**
  * Gets the name of the directory that the user wants to be
  * the target of the script that implements this class.
  *
  * The directory can be set with a command line, if not
  * then the user is asked.
  *
  * @return string The name of the directory.
  */
 protected function get_directory()
 {
     $validator = new FileSystem_ExistingDirectoryRelativeToProjectRootValidator();
     if ($this->has_arg('directory')) {
         $directory = $this->get_arg('directory');
         try {
             $validator->validate($directory);
         } catch (InputValidation_InvalidInputException $e) {
             fwrite(STDERR, $e->getMessage() . PHP_EOL);
             exit;
         }
     } else {
         $directory = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the name of the directory:' . PHP_EOL, $validator);
     }
     return $directory;
 }
 public static function get_validated_input($question, InputValidation_Validator $validator)
 {
     #while (TRUE) {
     #	try {
     #		echo $question;
     #
     #		$answer = trim(fgets(STDIN));
     #
     #		if ($validator->validate($answer)) {
     #			return $answer;
     #		}
     #	} catch (InputValidation_InvalidInputException $e) {
     #		echo $e->getMessage() . "\n";
     #
     #		continue;
     #	}
     #}
     return CLIScripts_UserInterrogationHelper::get_validated_input($question, $validator);
 }
 public static function get_user_entry_from_cli_choice()
 {
     /*
      * Get the array of users.
      */
     $all_user_entries = Admin_UsersHelper::get_all_user_entries();
     /*
      * Do a bit of array manipulation to put users
      * into a hash with the names as the key.
      */
     $users_hash = array();
     foreach ($all_user_entries as $user_entry) {
         $users_hash[$user_entry->get_name()] = $user_entry;
     }
     /*
      * Get the user's choice of user.
      */
     return $users_hash[CLIScripts_UserInterrogationHelper::get_choice_from_string_array(array_keys($users_hash))];
 }
 public function do_actions()
 {
     $page_class_name = CLIScripts_UserInterrogationHelper::get_validated_input('Please enter the name of page class: ' . PHP_EOL, new SiteTexts_PageClassNameValidator());
     SiteTexts_PagesHelper::set_page_class_name($page_class_name);
 }