Beispiel #1
0
 public function main()
 {
     $input = new \ezcConsoleInput();
     $output = new \ezcConsoleOutput();
     $input->registerOption(new \ezcConsoleOption('h', 'help'));
     $input->registerOption(new \ezcConsoleOption('p', 'process'));
     $input->process();
     if ($input->getOption("p")->value) {
         $parser = new PHPLpm\Parser();
         $result = $parser->parse(file_get_contents("_testdata/sample.php", 1));
         $table = new \ezcConsoleTable($output, 60);
         $table[0][0]->content = "Class";
         $table[0][1]->content = "Method";
         $table[0][2]->content = "Lines";
         $i = 1;
         foreach ($result as $class => $methods) {
             foreach ($methods as $method) {
                 $row = $table[$i];
                 $row[0]->content = $class;
                 $row[1]->content = $method["name"];
                 $row[2]->content = (string) $method["lines"];
                 $i++;
             }
         }
         $table->outputTable();
         print "\n";
         //print_r($result);
     }
 }
Beispiel #2
0
 /**
  * Displays messages
  *
  * @var string $message Message to display
  * @var string $type    Type of the message
  * @return void
  */
 public static function displayMessage($message, $type = 'info')
 {
     if ('info' == $type && !self::$consoleInput->getOption('verbose')->value) {
         return;
     } elseif ('debug' == $type && !self::$consoleInput->getOption('debug')->value) {
         return;
     }
     self::$consoleOutput->outputText("{$message}\n", $type);
 }
Beispiel #3
0
 /**
  * Prints the message of an occured error and exits the program.
  * This method is used to print an error message, as soon as an error
  * occurs end quit the program with return code -1. Optionally, the
  * method will trigger the help text to be printed after the error message.
  * 
  * @param string $message The error message to print
  * @param bool $printHelp Whether to print the help after the error msg.
  */
 private function raiseError($message, $printHelp = false)
 {
     $this->output->outputLine($message, 'error');
     $this->output->outputLine();
     if ($printHelp === true) {
         $this->output->outputText($this->input->getHelpText(ezcPersistentObjectSchemaGenerator::PROGRAM_DESCRIPTION), "help");
     }
     exit(-1);
 }
Beispiel #4
0
 /**
  * Prints the message of an occured error and exits the program.
  * This method is used to print an error message, as soon as an error
  * occurs end quit the program with return code -1. Optionally, the
  * method will trigger the help text to be printed after the error message.
  *
  * @param string $message The error message to print
  * @param bool $printHelp Whether to print the help after the error msg.
  */
 private function raiseError($message, $printHelp = false)
 {
     $this->output->outputLine($message, 'error');
     $this->output->outputLine();
     if ($printHelp === true) {
         $this->output->outputText($this->input->getHelpText(self::PROGRAM_DESCRIPTION), "help");
     }
     exit(-1);
 }
Beispiel #5
0
 /**
  * starts the command line interface for pFlow
  * @return void
  */
 public function run()
 {
     $this->setupInput();
     try {
         $this->input->process();
     } catch (\ezcConsoleOptionException $e) {
         die($e->getMessage() . "\nTry option -h to get a list of available options.\n");
     } catch (\ezcConsoleArgumentMandatoryViolationException $e) {
         die($e->getMessage() . "\nTry option -h to get a list of available options.\n");
     }
     if ($this->input->helpOptionSet()) {
         echo $this->input->getHelpText("\npFlow version " . self::VERSION . "\n\n" . "A tool for analysing control and data flow in PHP applications.");
     } else {
         // start generation
         $this->analyzer->setSources($this->input->getArguments(), $this->input->getOption('recursive')->value);
     }
 }
Beispiel #6
0
 /**
  * Generates a command line synopsis for the options and arguments.
  *
  * This method generates a synopsis string that lists the options and 
  * parameters available, indicating their usage. If $optionsFilter is
  * submitted, only the options named in this array (short or long variant) 
  * will be included in the synopsis.
  *
  * @param array(string) $optionsFilter
  * @return string
  */
 public function generateSynopsis(array $optionFilter = null)
 {
     $usedOptions = array('short' => array(), 'long' => array());
     $allowsArgs = true;
     $synopsis = '$ ' . (isset($argv) && sizeof($argv) > 0 ? $argv[0] : $_SERVER['argv'][0]) . ' ';
     foreach ($this->input->getOptions() as $option) {
         if ($optionFilter === null || in_array($option->short, $optionFilter) || in_array($option->long, $optionFilter)) {
             $synopsis .= $this->createOptionSynopsis($option, $usedOptions, $allowsArgs);
         }
     }
     if ($this->input->argumentDefinition === null) {
         // Old handling
         $synopsis .= " [[--] <args>]";
     } else {
         $synopsis .= "[--] " . $this->createArgumentsSynopsis();
     }
     return $synopsis;
 }
Beispiel #7
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     if (empty($arguments)) {
         self::showHelp();
         exit(1);
     }
     self::printVersionString();
     print "Line   Token                          Text\n" . str_repeat('-', 79) . "\n";
     foreach (new PHP_Token_Stream($arguments[0]) as $token) {
         if ($token instanceof PHP_Token_WHITESPACE) {
             $text = '';
         } else {
             $text = str_replace(array("\r", "\n"), '', (string) $token);
             if (strlen($text) > 40) {
                 $text = explode("\n", wordwrap($text, 40));
                 $text = $text[0];
             }
         }
         printf("%5d  %-30s %s\n", $token->getLine(), str_replace('PHP_Token_', '', get_class($token)), $text);
     }
 }
            }
        }
    }
}
if ($baseEnabled) {
    spl_autoload_register(array('ezcBase', 'autoload'));
}
require 'kernel/private/classes/ezautoloadgenerator.php';
require 'kernel/private/interfaces/ezpautoloadoutput.php';
require 'kernel/private/classes/ezpautoloadclioutput.php';
require 'kernel/private/options/ezpautoloadgeneratoroptions.php';
require 'kernel/private/structs/ezpautoloadfilefindcontext.php';
//}
// Setup console parameters
//{
$params = new ezcConsoleInput();
$helpOption = new ezcConsoleOption('h', 'help');
$helpOption->mandatory = false;
$helpOption->shorthelp = "Show help information";
$params->registerOption($helpOption);
$targetOption = new ezcConsoleOption('t', 'target', ezcConsoleInput::TYPE_STRING);
$targetOption->mandatory = false;
$targetOption->shorthelp = "The directory to where the generated autoload file should be written.";
$params->registerOption($targetOption);
$verboseOption = new ezcConsoleOption('v', 'verbose', ezcConsoleInput::TYPE_NONE);
$verboseOption->mandatory = false;
$verboseOption->shorthelp = "Whether or not to display more information.";
$params->registerOption($verboseOption);
$dryrunOption = new ezcConsoleOption('n', 'dry-run', ezcConsoleInput::TYPE_NONE);
$dryrunOption->mandatory = false;
$dryrunOption->shorthelp = "Whether a new file autoload file should be written.";
<?php

require 'ezc-setup.php';
$optionHandler = new ezcConsoleInput();
$file = new ezcConsoleOption('f', 'file', ezcConsoleInput::TYPE_STRING);
$file->mandatory = true;
$optionHandler->registerOption($file);
try {
    $optionHandler->process();
} catch (ezcConsoleException $e) {
    die($e->getMessage());
}
echo "Processing file: ", $optionHandler->getOption('f')->value, "\n";
Beispiel #10
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $html = $input->getOption('html')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $merge = $input->getOption('merge')->value;
     if (count($arguments) == 1) {
         self::printVersionString();
         $coverage = new PHP_CodeCoverage();
         $filter = $coverage->filter();
         if (empty($whitelist)) {
             $c = new ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $facade = new File_Iterator_Facade();
             $result = $facade->getFilesAsArray($arguments[0], '.cov');
             foreach ($files as $file) {
                 $coverage->merge(unserialize(file_get_contents($file)));
             }
         }
         if ($clover) {
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
         }
         if ($html) {
             $writer = new PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
         }
     } else {
         self::showHelp();
         exit(1);
     }
 }
Beispiel #11
0
 public function testGetHelpTextBinarySafe()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('ö', 'öder', ezcConsoleInput::TYPE_NONE, null, false, 'ööö äää ööö äää', 'ööö äää ööö äää ööö äää ööö äää ööö äää ööö äää'));
     $res = "Usage: \$ {$_SERVER['argv'][0]} [-ö]  [[--] <args>]" . PHP_EOL . 'Test with UTF-8' . PHP_EOL . 'characters...' . PHP_EOL . '' . PHP_EOL . '-ö / --öder  ööö äää' . PHP_EOL . '             ööö äää' . PHP_EOL . '             ööö äää' . PHP_EOL . '             ööö äää' . PHP_EOL . '             ööö äää' . PHP_EOL . '             ööö äää' . PHP_EOL;
     $this->assertEquals($res, $input->getHelpText('Test with UTF-8 characters...', 20, true), 'Help text not generated correctly.');
 }
Beispiel #12
0
 /**
  * @return \ezcConsoleInput
  */
 protected function setupInput()
 {
     $input = new \ezcConsoleInput();
     $this->versionOption = $input->registerOption(new \ezcConsoleOption('v', 'version'));
     $this->versionOption->shorthelp = 'Prints the version and exits';
     $this->versionOption->isHelpOption = TRUE;
     $this->helpOption = $input->registerOption(new \ezcConsoleOption('h', 'help'));
     $this->helpOption->isHelpOption = TRUE;
     $this->helpOption->shorthelp = 'Prints this usage information';
     $input->registerOption(new \ezcConsoleOption('', 'cache', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Enable cache and set cache filename'));
     $this->outputOption = $input->registerOption(new \ezcConsoleOption('o', 'output', \ezcConsoleInput::TYPE_STRING, 'STDOUT', FALSE, 'Output file for generated code (default: STDOUT)'));
     $this->pharOption = $input->registerOption(new \ezcConsoleOption('p', 'phar', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a phar archive of directory contents', NULL, array(new \ezcConsoleOptionRule($input->getOption('o')))));
     $input->registerOption(new \ezcConsoleOption('', 'all', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Add all files from src dir to phar', NULL, array(new \ezcConsoleOptionRule($input->getOption('p')))));
     $input->registerOption(new \ezcConsoleOption('', 'alias', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Provide explicit internal alias filename for phar', NULL, array(new \ezcConsoleOptionRule($input->getOption('p')))));
     $bzip2 = $input->registerOption(new \ezcConsoleOption('', 'bzip2', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with bzip2', NULL, array(new \ezcConsoleOptionRule($input->getOption('p')))));
     $gzip = $input->registerOption(new \ezcConsoleOption('', 'gzip', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with gzip', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))), array(new \ezcConsoleOptionRule($bzip2))));
     $bzip2->addExclusion(new \ezcConsoleOptionRule($gzip));
     $input->registerOption(new \ezcConsoleOption('', 'key', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Keyfile to use for signing phar archive', NULL, array(new \ezcConsoleOptionRule($input->getOption('p')))));
     $this->outputOption = $input->registerOption(new \ezcConsoleOption('', 'hash', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p)', NULL, array(new \ezcConsoleOptionRule($input->getOption('p'))), array(new \ezcConsoleOptionRule($input->getOption('key')))));
     $input->registerOption(new \ezcConsoleOption('i', 'include', \ezcConsoleInput::TYPE_STRING, '*.php', TRUE, 'File pattern to include (default: *.php)'));
     $input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'Name pattern to exclude'));
     $input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, '*', TRUE, 'Name pattern to include (default: *)'));
     $input->registerOption(new \ezcConsoleOption('e', 'exclude', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'File pattern to exclude'));
     $input->registerOption(new \ezcConsoleOption('b', 'basedir', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Basedir for filepaths'));
     $input->registerOption(new \ezcConsoleOption('t', 'template', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Path to code template to use'));
     $input->registerOption(new \ezcConsoleOption('', 'follow', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Enables following symbolic links', NULL, array(), array(new \ezcConsoleOptionRule($this->pharOption))));
     $input->registerOption(new \ezcConsoleOption('', 'format', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Dateformat string for timestamp'));
     $input->registerOption(new \ezcConsoleOption('', 'linebreak', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Linebreak style (CR, CR/LF or LF)'));
     $input->registerOption(new \ezcConsoleOption('', 'indent', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'String used for indenting (default: 3 spaces)'));
     $this->lintOption = $input->registerOption(new \ezcConsoleOption('', 'lint', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run lint on generated code'));
     $input->registerOption(new \ezcConsoleOption('', 'lint-php', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'PHP binary path for linting (default: /usr/bin/php or c:\\php\\php.exe)', NULL, array(new \ezcConsoleOptionRule($input->getOption('lint')))));
     $compat = $input->registerOption(new \ezcConsoleOption('c', 'compat', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Generate PHP 5.2 compliant code'));
     $this->staticOption = $input->registerOption(new \ezcConsoleOption('s', 'static', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a static require file'));
     $input->registerOption(new \ezcConsoleOption('', 'tolerant', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Ignore Class Redeclarations in the same file'));
     $trusting = $input->registerOption(new \ezcConsoleOption('', 'trusting', \ezcConsoleInput::TYPE_NONE, TRUE, FALSE, 'Do not check mimetype of files prior to parsing'));
     $paranoid = $input->registerOption(new \ezcConsoleOption('', 'paranoid', \ezcConsoleInput::TYPE_NONE, FALSE, FALSE, 'Do check mimetype of files prior to parsing', NULL, array(), array(new \ezcConsoleOptionRule($trusting))));
     $trusting->addExclusion(new \ezcConsoleOptionRule($paranoid));
     $this->onceOption = $input->registerOption(new \ezcConsoleOption('', 'once', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Use require_once in static require mode', NULL, array(new \ezcConsoleOptionRule($input->getOption('s')))));
     $input->registerOption(new \ezcConsoleOption('n', 'nolower', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Do not lowercase classnames for case insensitivity'));
     $input->registerOption(new \ezcConsoleOption('q', 'quiet', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run in quiet mode, no output'));
     $input->registerOption(new \ezcConsoleOption('1', 'prepend', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Prepend autoloader to stack', NULL, array(), array(new \ezcConsoleOptionRule($compat))));
     $input->registerOption(new \ezcConsoleOption('d', 'no-exception', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Disable exceptions on registration error'));
     $input->registerOption(new \ezcConsoleOption(NULL, 'var', \ezcConsoleInput::TYPE_STRING, array(), TRUE, 'Assign variable'));
     $input->argumentDefinition = new \ezcConsoleArguments();
     $input->argumentDefinition[0] = new \ezcConsoleArgument("directory");
     $input->argumentDefinition[0]->shorthelp = "The directory to process.";
     $input->argumentDefinition[0]->multiple = TRUE;
     return $input;
 }
Beispiel #13
0
 /**
  * Main method.
  */
 public function main()
 {
     $input = new ezcConsoleInput();
     $output = new ezcConsoleOutput();
     $input->registerOption(new ezcConsoleOption('', 'count-tests', ezcConsoleInput::TYPE_NONE, FALSE, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'log-xml', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'log-csv', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'cores', ezcConsoleInput::TYPE_STRING, 1));
     $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'verbose', ezcConsoleInput::TYPE_NONE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         $this->showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             $this->printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     if (empty($arguments)) {
         $this->showHelp();
         exit(1);
     }
     $countTests = $input->getOption('count-tests')->value;
     $excludes = $input->getOption('exclude')->value;
     $logXml = $input->getOption('log-xml')->value;
     $logCsv = $input->getOption('log-csv')->value;
     $cores = $input->getOption('cores')->value;
     $suffixes = array_map('trim', explode(',', $input->getOption('suffixes')->value));
     if ($input->getOption('verbose')->value !== FALSE) {
         $verbose = $output;
     } else {
         $verbose = NULL;
     }
     $this->printVersionString();
     $files = $this->findFiles($arguments, $excludes, $suffixes);
     if (empty($files)) {
         $this->showError("No files found to scan.\n");
     }
     $analyser = new PHPLOC_Analyser($verbose);
     if ($cores > 1 && extension_loaded('pcntl') && extension_loaded('sockets')) {
         $parallelAnalyser = new PHPLOC_ParallelAnalyser($cores);
         $count = $parallelAnalyser->countFiles($files, $countTests);
     } else {
         $count = $analyser->countFiles($files, $countTests);
     }
     $printer = new PHPLOC_TextUI_ResultPrinter_Text();
     $printer->printResult($count, $countTests);
     if ($logXml) {
         $printer = new PHPLOC_TextUI_ResultPrinter_XML();
         $printer->printResult($logXml, $count);
     }
     if ($logCsv) {
         $printer = new PHPLOC_TextUI_ResultPrinter_CSV();
         $printer->printResult($logCsv, $count);
     }
 }
Beispiel #14
0
 /**
  * Main method.
  */
 public function main()
 {
     $input = new \ezcConsoleInput();
     $input->registerOption(new \ezcConsoleOption('', 'clover', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'configuration', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'html', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'php', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'text', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'merge', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('', 'add-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('', 'process-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         $this->showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             $this->printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $configuration = $input->getOption('configuration')->value;
     $html = $input->getOption('html')->value;
     $php = $input->getOption('php')->value;
     $text = $input->getOption('text')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $addUncovered = $input->getOption('add-uncovered')->value;
     $processUncovered = $input->getOption('process-uncovered')->value;
     $merge = $input->getOption('merge')->value;
     $coverage = new \PHP_CodeCoverage();
     $filter = $coverage->filter();
     if ($configuration) {
         $this->handleConfiguration($configuration, $coverage);
     }
     if (count($arguments) == 1) {
         $this->printVersionString();
         if (empty($whitelist)) {
             $c = new \ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new \ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             $coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
             $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $facade = new \File_Iterator_Facade();
             $files = $facade->getFilesAsArray($arguments[0], '.cov');
             foreach ($files as $file) {
                 $coverage->merge(unserialize(file_get_contents($file)));
             }
         }
         if ($clover) {
             print "\nGenerating code coverage report in Clover XML format ...";
             $writer = new \PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
             print " done\n";
         }
         if ($html) {
             print "\nGenerating code coverage report in HTML format ...";
             $writer = new \PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
             print " done\n";
         }
         if ($php) {
             print "\nGenerating code coverage report in PHP format ...";
             $writer = new \PHP_CodeCoverage_Report_PHP();
             $writer->process($coverage, $php);
             print " done\n";
         }
         if ($text) {
             $writer = new \PHP_CodeCoverage_Report_Text();
             $writer->process($coverage, $text);
         }
     } else {
         $this->showHelp();
         exit(1);
     }
 }
Beispiel #15
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'php', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'text', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'add-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'process-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $html = $input->getOption('html')->value;
     $php = $input->getOption('php')->value;
     $text = $input->getOption('text')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $addUncovered = $input->getOption('add-uncovered')->value;
     $processUncovered = $input->getOption('process-uncovered')->value;
     $merge = $input->getOption('merge')->value;
     if (count($arguments) == 1) {
         self::printVersionString();
         $coverage = new PHP_CodeCoverage();
         $filter = $coverage->filter();
         if (empty($whitelist)) {
             $c = new ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             $coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
             $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $finder = new Symfony\Component\Finder\Finder();
             $finder->in($arguments[0])->name('*.cov');
             foreach ($finder as $file) {
                 $coverage->merge(unserialize(file_get_contents($file->getRealpath())));
             }
         }
         if ($clover) {
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
         }
         if ($html) {
             $writer = new PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
         }
         if ($php) {
             $writer = new PHP_CodeCoverage_Report_PHP();
             $writer->process($coverage, $php);
         }
         if ($text) {
             $writer = new PHP_CodeCoverage_Report_Text();
             $writer->process($coverage, $text);
         }
     } else {
         self::showHelp();
         exit(1);
     }
 }
Beispiel #16
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('', 'bootstrap', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'class', ezcConsoleInput::TYPE_NONE));
     $input->registerOption(new ezcConsoleOption('', 'test', ezcConsoleInput::TYPE_NONE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $bootstrap = $input->getOption('bootstrap')->value;
     $class = $input->getOption('class')->value;
     $test = $input->getOption('test')->value;
     if (empty($arguments) || !$class && !$test || $class && $test) {
         self::showHelp();
         exit(1);
     }
     if ($class) {
         $reflector = new ReflectionClass('PHPUnit_SkeletonGenerator_Class');
     } else {
         if ($test) {
             $reflector = new ReflectionClass('PHPUnit_SkeletonGenerator_Test');
         }
     }
     self::printVersionString();
     if ($bootstrap && file_exists($bootstrap)) {
         include $bootstrap;
     }
     $generator = $reflector->newInstanceArgs($arguments);
     $generator->write();
     printf('Wrote skeleton for "%s" to "%s".' . "\n", $generator->getOutClassName(), $generator->getOutSourceFile());
     exit(0);
 }
    /**
     * Sets up all the input options (cli arguments)
     *
     * @param ezcConsoleInput $input A not configured input instance
     * @return ezcConsoleInput Fully configured input instance
     */
    protected function cliInputOptions( $input )
    {
        $this->siteAccessOption = $input->registerOption(
            new ezcConsoleOption( 's', 'siteaccess',
                ezcConsoleInput::TYPE_STRING,
                null,
                false,
                "Which siteaccess to use"
        ));
        $this->helpOption = $input->registerOption(
            new ezcConsoleOption( 'h', 'help',
                ezcConsoleInput::TYPE_NONE,
                null,
                false,
                "Display this help message"
        ));
        $this->dryRunOption = $input->registerOption(
            new ezcConsoleOption( 'd', 'dry-run',
                ezcConsoleInput::TYPE_NONE,
                null,
                false,
                "Output what will be cleaned up"
        ));
        $this->subtreeNodeOption = $input->registerOption(
            new ezcConsoleOption( 't', 'subtree',
                ezcConsoleInput::TYPE_STRING,
                null,
                false,
                "Node id of subtree to process"
        ));
        $this->subtreeNodeOption->mandatory = true;

        $this->actionOption = $input->registerOption(
            new ezcConsoleOption( 'a', 'action',
                ezcConsoleInput::TYPE_STRING,
                null,
                false,
                "Which cleanup action to take 'unpublish' or 'orphans'"
        ));
        $this->actionOption->mandatory = true;

        return $input;
    }
Beispiel #18
0
    if ($handle = @opendir($dir)) {
        while (($file = readdir($handle)) !== false) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                $fileList[] = array('path' => $path, 'name' => $file, 'type' => 'dir');
                recursiveList($dir . '/' . $file, $path . '/' . $file, $fileList);
            } else {
                $fileList[] = array('path' => $path, 'name' => $file, 'type' => 'file');
            }
        }
        @closedir($handle);
    }
}
$input = new ezcConsoleInput();
$output = new ezcConsoleOutput();
$helpOption = $input->registerOption(new ezcConsoleOption('h', 'help'));
$helpOption->isHelpOption = true;
$helpOption->shorthelp = 'Display current help information.';
$extensionOption = $input->registerOption(new ezcConsoleOption('e', 'extension', ezcConsoleInput::TYPE_STRING));
$extensionOption->mandatory = true;
$extensionOption->shorthelp = 'Full path to the eZ Publish extension e.g \'/home/ls/public_html/ezp/extension/myextension\'';
$extensionNameOption = $input->registerOption(new ezcConsoleOption('n', 'extension-name', ezcConsoleInput::TYPE_STRING));
$extensionNameOption->mandatory = true;
$extensionNameOption->shorthelp = 'Extension name. e.g \'myextension\'';
try {
    $input->process();
} catch (ezcConsoleOptionException $e) {
    $output->outputLine($e->getMessage());
    exit;
Beispiel #19
0
 /**
  * Main method.
  */
 public function main()
 {
     $input = new ezcConsoleInput();
     $output = new ezcConsoleOutput();
     $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'recursive', ezcConsoleInput::TYPE_NONE));
     $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'verbose', ezcConsoleInput::TYPE_NONE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         $this->showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             $this->printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     if (empty($arguments)) {
         $this->showHelp();
         exit(1);
     }
     $excludes = $input->getOption('exclude')->value;
     $recursive = $input->getOption('recursive')->value;
     $suffixes = explode(',', $input->getOption('suffixes')->value);
     array_map('trim', $suffixes);
     if ($input->getOption('verbose')->value !== FALSE) {
         $verbose = $output;
     } else {
         $verbose = NULL;
     }
     $this->printVersionString();
     $files = $this->findFiles($arguments, $excludes, $suffixes);
     if (empty($files)) {
         $this->showError("No files found to scan.\n");
     }
     $detector = new PHPDCD_Detector($verbose);
     $result = $detector->detectDeadCode($files, $recursive);
     $printer = new PHPDCD_TextUI_ResultPrinter();
     $printer->printResult($result, $commonPath);
     unset($printer);
 }
Beispiel #20
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $output = new ezcConsoleOutput();
     $input->registerOption(new ezcConsoleOption('', 'exclude', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'log-pmd', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'min-lines', ezcConsoleInput::TYPE_INT, 5));
     $input->registerOption(new ezcConsoleOption('', 'min-tokens', ezcConsoleInput::TYPE_INT, 70));
     $input->registerOption(new ezcConsoleOption('', 'save-memory', ezcConsoleInput::TYPE_NONE, NULL, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'suffixes', ezcConsoleInput::TYPE_STRING, 'php', FALSE));
     $input->registerOption(new ezcConsoleOption('', 'quiet', ezcConsoleInput::TYPE_NONE, NULL, FALSE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('', 'verbose', ezcConsoleInput::TYPE_NONE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . PHP_EOL;
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $exclude = $input->getOption('exclude')->value;
     if (is_array($exclude) && count($exclude) == 1) {
         array_map('trim', explode(',', array_pop($exclude)));
     }
     $logPmd = $input->getOption('log-pmd')->value;
     $minLines = $input->getOption('min-lines')->value;
     $minTokens = $input->getOption('min-tokens')->value;
     $saveMemory = $input->getOption('save-memory')->value;
     $suffixes = array_map('trim', explode(',', $input->getOption('suffixes')->value));
     $quiet = $input->getOption('quiet')->value;
     if ($input->getOption('verbose')->value !== FALSE) {
         $verbose = $output;
     } else {
         $verbose = NULL;
     }
     if (!empty($arguments)) {
         $facade = new File_Iterator_Facade();
         $result = $facade->getFilesAsArray($arguments, $suffixes, array(), $exclude, TRUE);
         $files = $result['files'];
         $commonPath = $result['commonPath'];
         unset($result);
     } else {
         self::showHelp();
         exit(1);
     }
     if (empty($files)) {
         self::showError('No files found to scan.' . PHP_EOL);
     }
     self::printVersionString();
     if (!$saveMemory) {
         $strategy = new PHPCPD_Detector_Strategy_Default();
     } else {
         $strategy = new PHPCPD_Detector_Strategy_SaveMemory();
     }
     $detector = new PHPCPD_Detector($strategy, $verbose);
     $clones = $detector->copyPasteDetection($files, $minLines, $minTokens);
     $printer = new PHPCPD_TextUI_ResultPrinter();
     $printer->printResult($clones, $commonPath, !$quiet);
     unset($printer);
     if ($logPmd) {
         $pmd = new PHPCPD_Log_XML_PMD($logPmd);
         $pmd->processClones($clones);
         unset($pmd);
     }
     if (count($clones) > 0) {
         exit(1);
     }
 }
Beispiel #21
0
 * @package ConsoleTools
 * @version 1.6.1
 * @copyright Copyright (C) 2005-2010 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
require_once 'Base/src/base.php';
/**
 * Autoload ezc classes 
 * 
 * @param string $className 
 */
function __autoload($className)
{
    ezcBase::autoload($className);
}
$optionHandler = new ezcConsoleInput();
// Register simple parameter -h/--help
$optionHandler->registerOption(new ezcConsoleOption('h', 'help'));
// Register complex parameter -f/--file
$file = new ezcConsoleOption('f', 'file', ezcConsoleInput::TYPE_STRING, null, false, 'Process a file.', 'Processes a single file.');
$optionHandler->registerOption($file);
// Manipulate parameter -f/--file after registration
$file->multiple = true;
// Register another complex parameter that depends on -f and excludes -h
$dir = new ezcConsoleOption('d', 'dir', ezcConsoleInput::TYPE_STRING, null, true, 'Process a directory.', 'Processes a complete directory.', array(new ezcConsoleOptionRule($optionHandler->getOption('f'))), array(new ezcConsoleOptionRule($optionHandler->getOption('h'))));
$optionHandler->registerOption($dir);
// Register an alias for this parameter
$optionHandler->registerAlias('e', 'extended-dir', $dir);
// Process registered parameters and handle errors
try {
    $optionHandler->process(array('example_input.php', '-h'));
            $generator->appendEmptyLines();
            $generator->appendCustomCode( "public function $methodName" );
            $generator->appendCustomCode( '{' );
            $generator->indentLevel++;
            $generator->appendCustomCode( 'self::markTestIncomplete( "Not implemented" );' );
            $generator->indentLevel--;
            $generator->appendCustomCode( '}' );
        }
    }
}


// Set input options
// ---------------------------------------------------------------------------
$input = new ezcConsoleInput();

$helpOption = $input->registerOption( new ezcConsoleOption( 'h', 'help' ) );
$helpOption->shorthelp = "Show help";
$helpOption->isHelpOption = true;

$sourceFileOption = $input->registerOption( new ezcConsoleOption( 's', 'source-file' ) );
$sourceFileOption->shorthelp = "File containing class to generate tests from";
$sourceFileOption->mandatory = true;
$sourceFileOption->type = ezcConsoleInput::TYPE_STRING;

$destinationFileOption = $input->registerOption( new ezcConsoleOption( 'd', 'dest-file' ) );
$destinationFileOption->shorthelp = "File to write the tests to";
$destinationFileOption->mandatory = true;
$destinationFileOption->type = ezcConsoleInput::TYPE_STRING;
Beispiel #23
0
#!/usr/bin/env php
<?php 
require_once 'ezc/Base/ezc_bootstrap.php';
ezcBase::addClassRepository(dirname(__FILE__) . '/..', dirname(__FILE__) . '/..');
$input = new ezcConsoleInput();
$helpOption = $input->registerOption(new ezcConsoleOption('h', 'help'));
$helpOption->isHelpOption = true;
$input->argumentDefinition = new ezcConsoleArguments();
$input->argumentDefinition[0] = new ezcConsoleArgument("infile");
$input->argumentDefinition[0]->mandatory = false;
$input->argumentDefinition[0]->default = '-';
$input->argumentDefinition[0]->type = ezcConsoleInput::TYPE_STRING;
$input->argumentDefinition[0]->shorthelp = "pipe definition file";
$input->argumentDefinition[0]->longhelp = "Pipe XML definition file to convert or - to read from STDIN ( not implemented yet )";
try {
    $input->process();
    main($input);
} catch (Exception $e) {
    echo $e->getMessage();
    exit(1);
}
function main(ezcConsoleInput $input)
{
    $pipe = getPipe($input->argumentDefinition["infile"]->value);
    $dotVisitor = new ymcPipeDotVisitor();
    $pipe->accept($dotVisitor);
    echo $dotVisitor->getDot();
}
function getPipe($infile)
{
    // get XML String
Beispiel #24
0
        $res[$name] = $value;
    }
    return $res;
}
$out = new ezcConsoleOutput();
$out->formats->error->color = 'red';
$out->formats->error->style = array('bold');
$out->formats->error->target = ezcConsoleOutput::TARGET_STDERR;
$out->formats->headline_1->color = 'green';
$out->formats->headline_1->style = array('bold');
$out->formats->headline_2->color = 'cyan';
$out->formats->headline_2->style = array('bold');
$out->formats->headline_3->color = 'blue';
$out->formats->border->color = 'gray';
$out->formats->border->style = array('bold');
$in = new ezcConsoleInput();
$helpOpt = $in->registerOption(new ezcConsoleOption('h', 'help'));
$helpOpt->isHelpOption = true;
$helpOpt->shorthelp = 'Print help information.';
$helpOpt->longhelp = 'Display this help information about the program.';
$suiteOpt = $in->registerOption(new ezcConsoleOption('s', 'suite', ezcConsoleInput::TYPE_STRING, '*'));
$suiteOpt->shorthelp = 'Path pattern defining the client test suites to display data for.';
$suiteOpt->longhelp = 'This option may contain a path pattern as understood by glob(), defining the client test suites to display data for. An example would be "rfc" to only see the rfc tests or "r*" to see all suites starting with "r".';
$testOpt = $in->registerOption(new ezcConsoleOption('t', 'test', ezcConsoleInput::TYPE_STRING, '*'));
$testOpt->shorthelp = 'Path pattern defining the test cases to display data for.';
$testOpt->longhelp = 'This option may contain a path pattern as understood by glob(), defining the test cases to display data for. An example would be "get_*" to only see all test cases that start with "get_".';
$noColorOpt = $in->registerOption(new ezcConsoleOption('n', 'no-color'));
$noColorOpt->shorthelp = 'Switch of use of format codes (for logging).';
$noColorOpt->longhelp = 'Switches of the use of shell formatting codes, like color and style. This is particularly useful if you want to log the generated output.';
try {
    $in->process();
Beispiel #25
0
<?php

/**
 * Analyses a FOF song and gets tracks & difficulties
 */
include dirname(__FILE__) . '/lib/autoload.php';
$input = new ezcConsoleInput();
$dryRunOption = $input->registerOption(new ezcConsoleOption('d', 'dry-run', ezcConsoleInput::TYPE_NONE, false));
$quietOption = $input->registerOption(new ezcConsoleOption('q', 'quiet', ezcConsoleInput::TYPE_NONE, false));
$helpOption = $input->registerOption(new ezcConsoleOption('h', 'help'));
$verboseOption = $input->registerOption(new ezcConsoleOption('v', 'verbose', ezcConsoleInput::TYPE_NONE, false));
$input->argumentDefinition = new ezcConsoleArguments();
$input->argumentDefinition[0] = new ezcConsoleArgument("artist");
$input->argumentDefinition[0]->mandatory = true;
$input->argumentDefinition[0]->shorthelp = "The artist to search for";
$output = new ezcConsoleOutput();
$output->formats->info->color = 'blue';
$output->formats->error->color = 'red';
$output->formats->error->style = array('bold');
$output->formats->fatal->color = 'red';
$output->formats->fatal->style = array('bold', 'underlined');
$output->formats->fatal->bgcolor = 'black';
try {
    $input->process();
} catch (ezcConsoleArgumentMandatoryViolationException $e) {
    if ($helpOption->value === true) {
        $output->outputText($input->getHelpText("Auto-link by artist name"));
        exit;
    } else {
        $output->outputLine("No arguments given", "fatal");
        $output->outputText($input->getHelpText("Auto-link by artist name"));
 * GNU General Public License for more details.
 *
 * You should have received a copy of version 2.0 of the GNU General
 * Public License along with this program; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 * @category   helper script
 * @package    ymcExtensionLoader
 * @copyright  2010 by YMC AG. All rights reserved.
 * @license    GNU General Public License v2.0
 * @author     ymc-toko
 * @filesource
 */
require_once 'ezc/Base/ezc_bootstrap.php';
$input = new ezcConsoleInput();
$option = $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, null, FALSE));
$option->isHelpOption = TRUE;
$option->arguments = FALSE;
$option = $input->registerOption(new ezcConsoleOption('d', 'dir', ezcConsoleInput::TYPE_STRING, '.', FALSE, 'Search Directory.', 'Directory to search for php class files, defaults to .'));
$option->arguments = FALSE;
$option = $input->registerOption(new ezcConsoleOption('t', 'target', ezcConsoleInput::TYPE_STRING, './autoload', FALSE, 'autoload dir', 'The directory where to save the autoload file, defaults to ./autoload'));
$option->arguments = FALSE;
$option = $input->registerOption(new ezcConsoleOption('p', 'prefix', ezcConsoleInput::TYPE_STRING, null, FALSE, 'classes prefix', 'The prefix of the classes for which the autoload file should be created'));
$option->arguments = FALSE;
$input->registerOption(new ezcConsoleOption('b', 'basedir', ezcConsoleInput::TYPE_STRING, '.', FALSE, 'basedir for autoload paths', 'Paths in the autoload array are written relatively to this dir.  Defaults to .'));
try {
    $input->process();
} catch (ezcConsoleOptionException $e) {
    die($e->getMessage() . "\n");
}
Beispiel #27
0
 /**
  * Displays the help text
  *
  * @param ezcConsoleInput $consoleInput
  */
 protected static function displayHelp($consoleInput)
 {
     echo $consoleInput->getHelpText('eZ Publish Test Runner');
 }
Beispiel #28
0
 /**
  * Main method.
  */
 public function main()
 {
     $input = new \ezcConsoleInput();
     $input->registerOption(new \ezcConsoleOption('', 'exclude', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'log-pmd', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'min-lines', \ezcConsoleInput::TYPE_INT, 5));
     $input->registerOption(new \ezcConsoleOption('', 'min-tokens', \ezcConsoleInput::TYPE_INT, 70));
     $input->registerOption(new \ezcConsoleOption('', 'names', \ezcConsoleInput::TYPE_STRING, '*.php', FALSE));
     $input->registerOption(new \ezcConsoleOption('', 'quiet', \ezcConsoleInput::TYPE_NONE, NULL, FALSE));
     $input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'progress', \ezcConsoleInput::TYPE_NONE));
     $input->registerOption(new \ezcConsoleOption('', 'verbose', \ezcConsoleInput::TYPE_NONE));
     try {
         $input->process();
     } catch (\ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         $this->showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             $this->printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     if (empty($arguments)) {
         $this->showHelp();
         exit(1);
     }
     $excludes = $input->getOption('exclude')->value;
     $logPmd = $input->getOption('log-pmd')->value;
     $minLines = $input->getOption('min-lines')->value;
     $minTokens = $input->getOption('min-tokens')->value;
     $names = explode(',', $input->getOption('names')->value);
     $quiet = $input->getOption('quiet')->value;
     $verbose = $input->getOption('verbose')->value;
     array_map('trim', $names);
     if ($input->getOption('progress')->value !== FALSE) {
         $output = new \ezcConsoleOutput();
     } else {
         $output = NULL;
     }
     $this->printVersionString();
     $finder = new FinderFacade($arguments, $excludes, $names);
     $files = $finder->findFiles();
     if (empty($files)) {
         $this->showError("No files found to scan.\n");
     }
     $strategy = new DefaultStrategy();
     $detector = new Detector($strategy, $output);
     $clones = $detector->copyPasteDetection($files, $minLines, $minTokens);
     $printer = new ResultPrinter();
     $printer->printResult($clones, !$quiet, $verbose);
     unset($printer);
     if ($logPmd) {
         $pmd = new PMD($logPmd);
         $pmd->processClones($clones);
         unset($pmd);
     }
     if (count($clones) > 0) {
         exit(1);
     }
 }
Beispiel #29
0
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
ini_set('error_reporting', E_ALL);
ini_set('register_globals', 0);
ini_set('display_errors', 1);
ini_set("max_execution_time", "3600");
require_once dirname(__FILE__) . "/ezcomponents/Base/src/base.php";
function __autoload($className)
{
    ezcBase::autoload($className);
}
ezcBase::addClassRepository(dirname(__FILE__) . '/', dirname(__FILE__) . '/lib/autoloads');
$input = new ezcConsoleInput();
$helpOption = $input->registerOption(new ezcConsoleOption('s', 'siteaccess', ezcConsoleInput::TYPE_STRING));
$cronjobPartOption = $input->registerOption(new ezcConsoleOption('c', 'cronjob', ezcConsoleInput::TYPE_STRING));
$cronjobPathOption = $input->registerOption(new ezcConsoleOption('p', 'path', ezcConsoleInput::TYPE_STRING));
$extensionPartOption = $input->registerOption(new ezcConsoleOption('e', 'extension', ezcConsoleInput::TYPE_STRING));
try {
    $input->process();
} catch (ezcConsoleOptionException $e) {
    die($e->getMessage());
}
ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'erLhcoreClassLazyDatabaseConfiguration');
$instance = erLhcoreClassSystem::instance();
$instance->SiteAccess = $helpOption->value;
$instance->SiteDir = dirname(__FILE__) . '/';
$cfgSite = erConfigClassLhConfig::getInstance();
$defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
Beispiel #30
0
 /**
  * Helper to register and process supported CLI options into an ezcConsoleInput
  *
  * @throws CLIOptionsException
  * @return CLIOptions
  */
 protected function processOptions()
 {
     $input = new \ezcConsoleInput();
     $versionOption = $input->registerOption(new \ezcConsoleOption('v', 'version'));
     $versionOption->shorthelp = 'Prints the version and exits';
     $versionOption->isHelpOption = TRUE;
     $helpOption = $input->registerOption(new \ezcConsoleOption('h', 'help'));
     $helpOption->isHelpOption = TRUE;
     $helpOption->shorthelp = 'Prints this usage information';
     $input->registerOption(new \ezcConsoleOption('f', 'file', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Configuration file to load'));
     $c = $input->registerOption(new \ezcConsoleOption('c', 'collector', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run collector process only'));
     $g = $input->registerOption(new \ezcConsoleOption('g', 'generator', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run generator process only'));
     $g->addExclusion(new \ezcConsoleOptionRule($c));
     $c->addExclusion(new \ezcConsoleOptionRule($g));
     $input->registerOption(new \ezcConsoleOption(NULL, 'engines', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Show a list of available engines and exit'));
     $input->registerOption(new \ezcConsoleOption(NULL, 'enrichers', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Show a list of available enrichers and exit'));
     $input->registerOption(new \ezcConsoleOption(NULL, 'backends', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Show a list of available backends and exit'));
     $skel = $input->registerOption(new \ezcConsoleOption(NULL, 'skel', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Show a skeleton config xml file and exit'));
     $strip = $input->registerOption(new \ezcConsoleOption(NULL, 'strip', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Strip xml config when showing'));
     $strip->addDependency(new \ezcConsoleOptionRule($skel));
     try {
         $input->process();
         return new CLIOptions($input);
     } catch (\ezcConsoleException $e) {
         throw new CLIOptionsException($e->getMessage(), $e->getCode());
     }
 }