<commit_before><?php
class commands_AddJsonAction extends commands_AbstractChangedevCommand
{
	/**
	 * @return String
	 */
	function getUsage()
	{
		return "<moduleName> <actionName>";
	}

	/**
	 * @return String
	 */
	function getDescription()
	{
		return "add a JSON action";
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 */
	protected function validateArgs($params, $options)
	{
		return count($params) == 2;
	}

	/**
	 * @param Integer $completeParamCount the parameters that are already complete in the command line
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @return String[] or null
	 */
	function getParameters($completeParamCount, $params, $options, $current)
	{
		if ($completeParamCount == 0)
		{
			$components = array();
			foreach (glob("modules/*", GLOB_ONLYDIR) as $module)
			{
				$components[] = basename($module);
			}
			return $components;
		}
		return null;
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @see c_ChangescriptCommand::parseArgs($args)
	 */
	function _execute($params, $options)
	{
		$this->message("== Add action ==");

		$moduleName = $params[0];
		$actionName = ucfirst($params[1]);

		$this->loadFramework();

		$actionFile = FileResolver::getInstance()->setPackageName('modules_'.$moduleName)->setDirectory('actions')->getPath($actionName.'Action.class.php');
		if(file_exists($actionFile))
		{
			$this->warnMessage('Action "'.$actionName.'" already exists in module '.$moduleName.'".');
		}

		$actionFile = 'modules/'.$moduleName.'/actions/'.$actionName.'Action.class.php';
		$moduleGenerator = new builder_ModuleGenerator($moduleName);
		$moduleGenerator->setAuthor($this->getAuthor());
		$result = $moduleGenerator->generateJSONAction($actionName);
			<commit_msg>[FIX] In add-json-action command, if the "actions" directory does not exist, create it.<commit_after><?php
class commands_AddJsonAction extends commands_AbstractChangedevCommand
{
	/**
	 * @return String
	 */
	function getUsage()
	{
		return "<moduleName> <actionName>";
	}

	/**
	 * @return String
	 */
	function getDescription()
	{
		return "add a JSON action";
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 */
	protected function validateArgs($params, $options)
	{
		return count($params) == 2;
	}

	/**
	 * @param Integer $completeParamCount the parameters that are already complete in the command line
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @return String[] or null
	 */
	function getParameters($completeParamCount, $params, $options, $current)
	{
		if ($completeParamCount == 0)
		{
			$components = array();
			foreach (glob("modules/*", GLOB_ONLYDIR) as $module)
			{
				$components[] = basename($module);
			}
			return $components;
		}
		return null;
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @see c_ChangescriptCommand::parseArgs($args)
	 */
	function _execute($params, $options)
	{
		$this->message("== Add action ==");

		$moduleName = $params[0];
		$actionName = ucfirst($params[1]);

		$this->loadFramework();

		$actionFile = FileResolver::getInstance()->setPackageName('modules_'.$moduleName)->setDirectory('actions')->getPath($actionName.'Action.class.php');
		if(file_exists($actionFile))
		{
			$this->warnMessage('Action "'.$actionName.'" already exists in module '.$moduleName.'".');
		}

		$dir = 'modules/'.$moduleName.'/actions/';
		if (!is_dir($dir))
		{
			f_util_FileUtils::mkdir($dir);
		}
		
		$actionFile = 'modules/'.$moduleName.'/actions/'.$actionName.'Action.class.php';
		$moduleGenerator = new builder_ModuleGenerator($moduleName);
		$moduleGenerator->setAuthor($this->getAuthor());
		$result = $moduleGenerator->generateJSONAction($actionName);
			
{'fraction_non_alphanumeric': 0.15066263659614043, 'fraction_numerical': 0.001860032550569635, 'mean_word_length': 4.480254777070064, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7571663', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1254, 'n_words': 343}