public function main()
{
if (!empty($this->params['exclude'])) {
$this->_exclude = explode(',', $this->params['exclude']);
}
if (isset($this->params['files']) && !is_array($this->params['files'])) {
$this->_files = explode(',', $this->params['files']);
}
if (isset($this->params['paths'])) {
$this->_paths = explode(',', $this->params['paths']);
} elseif (isset($this->params['plugin'])) {
$plugin = Inflector::camelize($this->params['plugin']);
if (!Plugin::loaded($plugin)) {
Plugin::load($plugin);
}
$this->_paths = [Plugin::classPath($plugin)];
$this->params['plugin'] = $plugin;
} else {
$this->_getPaths();
}
if (isset($this->params['extract-core'])) {
$this->_extractCore = !(strtolower($this->params['extract-core']) === 'no');
} else {
$response = $this->in('Would you like to extract the messages from the CakePHP core?', ['y', 'n'], 'n');
$this->_extractCore = strtolower($response) === 'y';
}
if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
$this->_exclude = array_merge($this->_exclude, App::path('Plugin'));
}
if (!empty($this->params['validation-domain'])) {
$this->_validationDomain = $this->params['validation-domain'];
}
if ($this->_extractCore) {
$this->_paths[] = CAKE;
}
if (isset($this->params['output'])) {
$this->_output = $this->params['output'];
} elseif (isset($this->params['plugin'])) {
$this->_output = $this->_paths[0] . 'Locale';
} else {
$message = "What is the path you would like to output?\n[Q]uit";
while (true) {
$response = $this->in($message, null, rtrim($this->_paths[0], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'Locale');
if (strtoupper($response) === 'Q') {
$this->err('Extract Aborted');
$this->_stop();
return;
}
if ($this->_isPathUsable($response)) {
$this->_output = $response . DIRECTORY_SEPARATOR;
break;
}
$this->err('');
$this->err('<error>The directory path you supplied was ' . 'not found. Please try again.</error>');
$this->out();
}
}
if (isset($this->params['merge'])) {
$this->_merge = !(strtolower($this->params['merge']) === 'no');
} else {
$this->out();
$response = $this->in('Would you like to merge all domain strings into the default.pot file?', ['y', 'n'], 'n');
$this->_merge = strtolower($response) === 'y';
}
if (empty($this->_files)) {
$this->_searchFiles();
}
$this->_output = rtrim($this->_output, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if (!$this->_isPathUsable($this->_output)) {
$this->err(sprintf('The output directory %s was not found or writable.', $this->_output));
$this->_stop();
return;
}
$this->_extract();
}