/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { try { $oldComponent = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[3], $arguments[2]); $newComponent = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[5], $arguments[4]); } catch (\Exception $ex) { throw new CommandException('Invalid arguments passed. Please check the parameters or run help command to see the options'); } if ($oldComponent == $newComponent) { $this->interface->show('Nothing to do'); return; } if (!$oldComponent->exists()) { throw new CommandException('No such component "' . $oldComponent->getName() . '" of type ' . $oldComponent->getType()); } $toBeCustomized = false; if (isset($arguments[6])) { $toBeCustomized = $arguments[6] == 'customized'; } if (!$this->interface->yesNo('This comes without any warranty. Are your sure you want to copy the component?')) { return; } $oldComponent->copy($newComponent->getName(), $newComponent->getType(), $toBeCustomized); $this->interface->show('Done'); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { if (!$this->interface->yesNo('Do you really want to irrevocably delete ' . $arguments[2] . ' "' . $arguments[3] . '"?')) { return; } $component = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[3], $arguments[2]); $component->remove(); $this->interface->show('Done'); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { // The following tasks will be done by Apps: // Get package info // Recursively get all dependencies // Foreach package to install (sorted, the one without any dependencies first): // Download package $comp = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[2]); $comp->install(); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { if (!$this->interface->yesNo('Removing workbench requires re-installing workbench to use it again. Are you sure?')) { return; } // Remove component from Db and FileSystem $component = new \Cx\Core\Core\Model\Entity\ReflectionComponent('Workbench', 'core_module'); $component->remove(); // Remove additional files (config, command line script) foreach ($this->interface->getWorkbench()->getFileList() as $file) { if (is_dir($file)) { \Cx\Lib\FileSystem\FileSystem::delete_folder(ASCMS_DOCUMENT_ROOT . $file, true); } else { \Cx\Lib\FileSystem\FileSystem::delete_file(ASCMS_DOCUMENT_ROOT . $file); } } $this->interface->show('Done'); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { $comp = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[3], $arguments[2]); $customized = false; if (isset($arguments[5])) { if ($arguments[5] == 'customized') { $customized = true; } $arguments[4] = $arguments[5]; } $zipPath = $arguments[4]; if (file_exists($zipPath)) { if (!$this->interface->yesNo('File is already exists. Do you want to overwrite it?')) { return; } } $comp->pack($zipPath, $customized); $this->interface->show('Component exported successfully.'); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { $oldComponent = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[3], $arguments[2]); $newComponent = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[5], $arguments[4]); if ($oldComponent == $newComponent) { $this->interface->show('Nothing to do'); return; } if (!$oldComponent->exists()) { throw new CommandException('No such component "' . $oldComponent->getName() . '" of type ' . $oldComponent->getType()); } $toBeCustomized = false; if (isset($arguments[6])) { $toBeCustomized = $arguments[6] == 'customized'; } if (!$this->interface->yesNo('This comes without any warranty. Are your sure you want to move the component?')) { return; } $oldComponent->move($newComponent->getName(), $newComponent->getType(), $toBeCustomized); $this->interface->show('Done'); }
/** * Execute this command * @param array $arguments Array of commandline arguments */ public function execute(array $arguments) { $component = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[3], $arguments[2]); $component->deactivate(); $this->interface->show('Done'); }
public function executeCommand($command, $arguments) { switch ($command) { case 'help': echo 'Cloudrexx command mode help. '; //if (count($arguments)) echo 'Synopsis: cx(.bat) <command> [<parameter>] Use »cx(.bat) help <command>« for more info about a command Available commands: '; $commands = $this->cx->getCommands(); $commandPerComponent = array(); foreach ($commands as $command => $component) { if (!isset($commandPerComponent[$component->getName()])) { $commandPerComponent[$component->getName()] = array(); } $commandPerComponent[$component->getName()][$command] = $component; } foreach ($commandPerComponent as $componentName => $commands) { $component = current($commands); echo $component->getType() . ' "' . $componentName . '" '; foreach ($commands as $command => $component) { echo "\t" . $command . ' - ' . $component->getCommandDescription($command, true) . ' '; } } break; case 'status': // prepare file list // if no argument given: // check complete installation // if one argument given: // treat as path // if two arguments given: // treat as component type and name // foreach file in file list $files = array('/var/www/CxTrunk/index2.php'); $fileCount = array('customized' => 0, 'irregular' => 0, 'unused' => 0, 'deleted' => 0, 'normal' => 0); foreach ($files as $file) { $fileState = $this->getFileState($file); $fileCount[$fileState]++; if ($fileState == 'normal') { continue; } echo ' ' . substr($fileState, -1) . ' ' . $file . "\r\n"; } $summary = array(); foreach ($fileCount as $type => $count) { $summary[] = $count . ' files ' . $type; } echo implode(', ', $summary); break; case 'diff': // prepare file list // if no argument given: // check complete installation // if one argument given: // treat as path // if two arguments given: // treat as component type and name foreach ($files as $file) { $fileState = $this->getFileState($file); if ($fileState != 'customized') { continue; } // execute diff command for file } break; case 'version': global $_CONFIG; echo $_CONFIG['coreCmsName'] . ' ' . ' ' . $_CONFIG['coreCmsEdition'] . ' \'' . $_CONFIG['coreCmsCodeName'] . '\' ' . $_CONFIG['coreCmsVersion'] . ' ' . $_CONFIG['coreCmsStatus']; break; case 'install': echo "BETA!!\r\n"; try { $component = new \Cx\Core\Core\Model\Entity\ReflectionComponent($arguments[1]); $component->install(); } catch (\BadMethodCallException $e) { echo 'Error: ' . $e->getMessage(); } break; case 'uninstall': echo "TODO!!\r\n"; break; } echo ' '; }