/** * Executa comando * * @param Object $oInput * @param Object $oOutput * @access public * @return void */ public function execute($oInput, $oOutput) { $oParametros = new \StdClass(); $oParametros->aArquivos = $oInput->getArgument('arquivos'); $oParametros->iTag = ltrim(strtoupper($oInput->getOption('tag')), 'T'); $oParametros->aMensagens = $oInput->getOption('message'); $oParametros->sData = $oInput->getOption('date'); $oArquivoModel = new ArquivoModel(); $aArquivosCommitados = $oArquivoModel->getCommitados($oParametros); if (empty($aArquivosCommitados)) { throw new \Exception("Nenhum arquivo encontrado."); } $oOutput->writeln(""); $oBuscaOutputFormatter = new OutputFormatterStyle('red', null, array()); $oOutput->getFormatter()->setStyle('busca', $oBuscaOutputFormatter); foreach ($aArquivosCommitados as $oDadosCommit) { $sTitulo = "- <comment>" . date('d/m/Y', strtotime($oDadosCommit->date)) . "</comment> as " . date('H:s:i', strtotime($oDadosCommit->date)); $sTitulo .= " " . count($oDadosCommit->aArquivos) . " arquivo(s) commitado(s)"; $oOutput->writeln($sTitulo); if (!empty($oDadosCommit->title)) { $oOutput->writeln("\n " . $oDadosCommit->title); } $oTabela = new \Table(); $oTabela->setHeaders(array('1', '1', '1', '1')); foreach ($oDadosCommit->aArquivos as $oArquivo) { $sArquivo = $this->getApplication()->clearPath($oArquivo->name); $sTag = $oArquivo->tag; $sMensagem = $oArquivo->message; foreach ($oParametros->aArquivos as $sParametroArquivo) { $sArquivo = $this->colorirBusca($sArquivo, $sParametroArquivo, 'busca'); } if (!empty($oParametros->iTag)) { $sTag = $this->colorirBusca($oArquivo->tag, $oParametros->iTag, 'busca'); } if (!empty($oParametros->aMensagens)) { foreach ($oParametros->aMensagens as $sMensagemBuscar) { $sMensagem = $this->colorirBusca($sMensagem, $sMensagemBuscar, 'busca'); } } $oTabela->addRow(array($oArquivo->type, " {$sArquivo}", " {$sTag}", " {$sMensagem}")); } $oOutput->writeln(" " . str_replace("\n", "\n ", $oTabela->render(true))); } }
/** * Executa o comando * * @param Object $oInput * @param Object $oOutput * @access public * @return void */ public function execute($oInput, $oOutput) { $lImportarHistorico = $oInput->getOption('import'); $oParametros = new StdClass(); $oParametros->aArquivos = $oInput->getArgument('arquivos'); $oParametros->iTag = $oInput->getOption('tag'); $oParametros->aMensagens = $oInput->getOption('message'); $oParametros->sUsuario = $oInput->getOption('user'); $oParametros->sData = $oInput->getOption('date'); $this->oOutput = $oOutput; $this->oInput = $oInput; $this->oModel = $this->getApplication()->getModel(); $this->oDataBase = $this->oModel->getDataBase(); if (!empty($lImportarHistorico)) { return $this->importarHistorico(); } $aHistorico = $this->getHistorico($oParametros); if (empty($aHistorico)) { throw new Exception("Histórico não encontrado."); } $oTabela = new Table(); $oTabela->setHeaders(array('Arquivo', 'Autor', 'Data', 'Hora', 'Versão', 'Tag', 'Mensagem')); foreach ($aHistorico as $oArquivo) { $sArquivo = $this->getApplication()->clearPath($oArquivo->name); $sAutor = $oArquivo->author; $sData = date('d/m/Y', strtotime($oArquivo->date)); $sHora = date('H:i:s', strtotime($oArquivo->date)); $sVersao = $oArquivo->revision; $sTags = implode(',', $oArquivo->tags); $sMensagem = Encode::toUTF8($oArquivo->message); $oTabela->addRow(array($sArquivo, $sAutor, $sData, $sHora, $sVersao, $sTags, $sMensagem)); } $sOutput = $oTabela->render(); $iColunas = array_sum($oTabela->getWidths()); $iColunas += count($oTabela->getWidths()) * 2; $iColunas += count($oTabela->getWidths()) - 1; if ($iColunas > \Shell::columns()) { $this->getApplication()->less($sOutput); return; } $oOutput->writeln($sOutput); }
/** * Runs the commands given * * @return void * @author Dan Cox */ public function runProcess($command) { $args = explode(' ', $this->DI->get('mask')->replace($command)); $p = $this->hasDefinition($args); if (!$p) { $process = $this->DI->get('skeletonprocess'); $process->build(['directory' => $this->input->getArgument('directory'), 'verbose' => $this->input->getOption('output') ? TRUE : FALSE]); $p = $process->setArguments($args)->getProcess(); } try { $p->mustRun(); $cmd = $p->getCommandLine(); } catch (\Exception $e) { $this->output->writeln($e->getMessage()); return false; } $this->output->writeln("Successfully ran command: {$cmd}"); return true; }
/** * Executa o comando * * @param Object $oInput * @param Object $oOutput * @access public * @return void */ public function execute($oInput, $oOutput) { $this->sArquivoConfiguracoes = CONFIG_DIR . basename($this->getApplication()->getModel()->getProjeto()->name) . '_config.json'; if ($oInput->getOption('restart')) { $this->criarArquivoConfiguracoes(); $oOutput->writeln("<info>Configurações reiniciadas.</info>"); return; } if (!file_exists($this->sArquivoConfiguracoes)) { $this->criarArquivoConfiguracoes(); } /** * Editar usando editor */ if ($oInput->getOption('edit')) { $iStatus = $this->editarArquivoConfiguracoes(); if ($iStatus > 0) { throw new Exception('Não foi possivel editar configurações'); } return $iStatus; } $oConfig = new Config($this->sArquivoConfiguracoes); $sOutput = PHP_EOL; $aIgnore = $oConfig->get('ignore'); $iTagRelease = $oConfig->get('tag')->release; $tagsSprint = $oConfig->get('tag')->sprint; $sOutput .= "- <comment>Arquivo:</comment> " . PHP_EOL; $sOutput .= " " . $this->sArquivoConfiguracoes . PHP_EOL; /** * Ignorar */ if (!empty($aIgnore)) { $sOutput .= PHP_EOL; $sOutput .= "- <comment>Ignorar:</comment>" . PHP_EOL; $sOutput .= ' ' . implode(PHP_EOL . ' ', $aIgnore) . PHP_EOL; } /** * Tags */ if (!empty($iTagRelease) || !empty($tagsSprint)) { $sOutput .= PHP_EOL; $sOutput .= "- <comment>Tags:</comment>" . PHP_EOL; if (!empty($iTagRelease)) { $sOutput .= PHP_EOL; $sOutput .= " <comment>Release:</comment>" . PHP_EOL; $sOutput .= ' ' . $iTagRelease . PHP_EOL; } if (!empty($tagsSprint)) { if (is_array($tagsSprint)) { $sOutput .= PHP_EOL; $sOutput .= " <comment>Sprint:</comment>" . PHP_EOL; $sOutput .= ' ' . implode(', ', $tagsSprint) . PHP_EOL; } if (is_object($tagsSprint)) { $sOutput .= PHP_EOL; $sOutput .= " <comment>Sprint:</comment>" . PHP_EOL; foreach ($tagsSprint as $sTag => $sDescricao) { $sOutput .= ' ' . $sTag; if (!empty($sDescricao)) { $sOutput .= ': ' . $sDescricao; } $sOutput .= PHP_EOL; } } } } $oOutput->writeln($sOutput); }
/** * Executa comando * * @param Object $oInput * @param Object $oOutput * @access public * @return void */ public function execute($oInput, $oOutput) { if (!file_exists('CVS/Repository')) { throw new Exception('Diretório atual não é um repositorio CVS.'); } $sDiretorioAtual = getcwd(); $sRepositorio = trim(file_get_contents('CVS/Repository')); $sArquivoBanco = CONFIG_DIR . $sRepositorio . '.db'; $sArquivoConfig = CONFIG_DIR . $sRepositorio . '_config.json'; /** * Força inicialização do projeto */ if ($oInput->getOption('force')) { /** * Remove arquivo do banco de dados */ if (file_exists($sArquivoBanco)) { if (!unlink($sArquivoBanco)) { throw new Exception("Não foi possivel remover banco de dados: " . $sArquivoBanco); } } /** * Remove arquivo de configuração */ if (file_exists($sArquivoConfig)) { if (!unlink($sArquivoConfig)) { throw new Exception("Não foi possivel remover configurações: " . $sArquivoConfig); } } } /** * Arquivo já existe, verifica se projeto já foi inicializado */ if (file_exists($sArquivoBanco)) { $oDataBase = new FileDataBase($sArquivoBanco); $aProjetos = $oDataBase->selectAll("select name, path from project where name = '{$sRepositorio}' or path = '{$sDiretorioAtual}'"); /** * Diretorio atual ja inicializado */ foreach ($aProjetos as $oProjeto) { if ($oProjeto->name == $sRepositorio || $oProjeto->path == $sDiretorioAtual) { $oOutput->writeln(sprintf('<info>"%s" já inicializado</info>', $sRepositorio)); return true; } } } /** * Diretório onde aplicação guarda arquivos de configuracão e banco de dados */ if (!is_dir(CONFIG_DIR) && !mkdir(CONFIG_DIR)) { throw new Exception('Não foi possivel criar diretório: ' . CONFIG_DIR); } /** * Cria copia do arquivo do banco */ $lArquivoConfiguracoes = copy(APPLICATION_DIR . 'cvsgit/install/config.json', $sArquivoConfig); if (!$lArquivoConfiguracoes) { throw new Exception("Não foi possivel criar arquivo de configurações no diretório: " . $sArquivoConfig); } /** * Cria copia do arquivo de configuracao */ $lArquivoBancoDados = copy(APPLICATION_DIR . 'cvsgit/install/cvsgit.db', $sArquivoBanco); if (!$lArquivoBancoDados) { throw new Exception("Não foi possivel criar arquivo do banco de dados no diretório: " . CONFIG_DIR); } $oDataBase = new FileDataBase($sArquivoBanco); $oDataBase->begin(); $oDataBase->insert('project', array('name' => $sRepositorio, 'path' => $sDiretorioAtual, 'date' => date('Y-m-d H:i:s'))); $oOutput->writeln(sprintf('<info>"%s" inicializado</info>', $sRepositorio)); $oDataBase->commit(); }
/** * validate * * @author Joe Stump <*****@*****.**> * @access public * @return mixed */ function validate() { if ($this->_request->getOption('avsCheck') === true) { if ($this->getAVSCode() != PAYMENT_PROCESS_AVS_MATCH) { return PEAR::raiseError('AVS check failed', PAYMENT_PROCESS_ERROR_AVS); } } $paymentType = $this->_request->_payment->_type; if ($this->_request->getOption('cvvCheck') === true && $paymentType == 'CreditCard') { if ($this->getCvvCode() != PAYMENT_PROCESS_CVV_MATCH) { return PEAR::raiseError('CVV check failed', PAYMENT_PROCESS_ERROR_CVV); } } if ($this->getCode() != PAYMENT_PROCESS_RESULT_APPROVED) { return PEAR::raiseError($this->getMessage(), PAYMENT_PROCESS_RESULT_DECLINED); } return true; }
/** * Render element close tag * * @return string */ public function closeTag() { self::$indCount--; $str = self::newLine(sprintf('</%s>', $this->_element->getAttribute('type') ?: $this->_element->getOption('tag'))); return $str; }