/**
  * Harvest a single repository.
  *
  * @param string $target   Name of repo (used for target directory)
  * @param array  $settings Settings for the harvester.
  *
  * @return void
  * @throws \Exception
  */
 protected function harvestSingleRepository($target, $settings)
 {
     $settings['from'] = $this->opts->getOption('from');
     $settings['until'] = $this->opts->getOption('until');
     $settings['silent'] = false;
     $harvest = $this->factory->getHarvester($target, $this->getHarvestRoot(), $this->getHttpClient(), $settings);
     $harvest->launch();
 }
        echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
        exit(2);
    }
}
// Setup autoloading
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write plugin map file; if not provided, assumes "plugin_classmap.php" in library directory', 'append|a' => 'Append to plugin map file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file');
try {
    $opts = new Console\Getopt($rules);
    $opts->parse();
} catch (Console\Exception\RuntimeException $e) {
    echo $e->getUsageMessage();
    exit(2);
}
if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit;
}
$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
    $path = $_SERVER['PWD'];
}
if (isset($opts->l)) {
    $libraryPath = $opts->l;
    $libraryPath = rtrim($libraryPath, '/\\') . DIRECTORY_SEPARATOR;
    if (!is_dir($libraryPath)) {
        echo "Invalid library directory provided" . PHP_EOL . PHP_EOL;
        echo $opts->getUsageMessage();
        exit(2);
    }
Example #3
0
} elseif (false === (include $libPath . '/Zend/Loader/StandardAutoloader.php')) {
    echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
    exit(2);
}
// Setup autoloading
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$rules = array('help|h' => 'Get usage message', 'docbook|d-s' => 'Docbook file to convert', 'output|o-s' => 'Output file in reStructuredText format; By default assumes <docbook>.rst"');
try {
    $opts = new Console\Getopt($rules);
    $opts->parse();
} catch (Console\Exception\RuntimeException $e) {
    echo $e->getUsageMessage();
    exit(2);
}
if (!$opts->getOptions() || $opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit(0);
}
$docbook = $opts->getOption('d');
if (!file_exists($docbook)) {
    echo "Error: the docbook file {$docbook} doesn't exist." . PHP_EOL;
    exit(2);
}
$rstFile = $opts->getOption('o');
if (empty($rstFile)) {
    $rstFile = $docbook;
    if ('.xml' === substr($rstFile, -4)) {
        $rstFile = substr($rstFile, 0, strlen($docbook) - 4);
    }
    $rstFile .= '.rst';
Example #4
0
 public function run()
 {
     switch ($this->mainArgv) {
         case 'generate':
             $gen = new Generators\Generator($this);
             $gen->parseCmd();
             break;
         case 'assets':
             $rules = ['assets' => '', 'action' => ''];
             $opts = new Zend\Console\Getopt($rules);
             $argv = $opts->getArguments();
             if (empty($argv[1])) {
                 $this->terminate("Missing argument 2");
             }
             \Rails::resetConfig('production');
             switch ($argv[1]) {
                 case 'compile:all':
                     \Rails::assets()->setConsole($this);
                     \Rails::assets()->compileAll();
                     break;
                 case strpos($argv[1], 'compile:') === 0:
                     $parts = explode(':', $argv[1]);
                     if (empty($parts[1])) {
                         $this->terminate("Missing asset name to compile");
                     }
                     \Rails::assets()->setConsole($this);
                     \Rails::assets()->compileFile($parts[1]);
                     break;
                 default:
                     $this->terminate("Unknown action for assets");
                     break;
             }
             break;
         case 'routes':
             $routes = $this->createRoutes();
             $rules = ['routes' => '', 'f-s' => ''];
             $opts = new Zend\Console\Getopt($rules);
             if ($filename = $opts->getOption('f')) {
                 if (true === $filename) {
                     $logFile = \Rails::config()->paths->log->concat('routes.log');
                 } else {
                     $logFile = \Rails::root() . '/' . $filename;
                 }
                 file_put_contents($logFile, $routes);
             }
             $this->write($routes);
             break;
             /**
              * Install database.
              */
         /**
          * Install database.
          */
         case 'db:create':
             $m = new \Rails\ActiveRecord\Migration\Migrator();
             $m->loadSchema();
             break;
             /**
              * Run all/pending migrations.
              * Creates migrations table as well.
              */
         /**
          * Run all/pending migrations.
          * Creates migrations table as well.
          */
         case 'db:migrate':
             $m = new \Rails\ActiveRecord\Migration\Migrator();
             $m->run();
             break;
             /**
              * Runs seeds.
              */
         /**
          * Runs seeds.
          */
         case 'db:seed':
             $m = new \Rails\ActiveRecord\Migration\Migrator();
             $m->runSeeds();
             break;
         case 'db:schema:dump':
             $dumper = new \Rails\ActiveRecord\Schema\Dumper(\Rails\ActiveRecord\ActiveRecord::connection());
             $dumper->export(\Rails::root() . '/db/schema.sql');
             break;
     }
 }
Example #5
0
 define('DS', DIRECTORY_SEPARATOR);
 define('PHPOOLE_DIRNAME', '_phpoole');
 $websitePath = '';
 //getcwd();
 // Defines rules
 $rules = array('help|h' => 'Get PHPoole usage message', 'init|i-s' => 'Build a new PHPoole website (<force>)', 'generate|g' => 'Generate static files', 'serve|s' => 'Start built-in web server', 'deploy|d' => 'Deploy static files', 'list|l' => 'Lists content');
 // Get and parse console options
 try {
     $opts = new Getopt($rules);
     $opts->parse();
 } catch (ConsoleException $e) {
     echo $e->getUsageMessage();
     exit(2);
 }
 // help option
 if ($opts->getOption('help') || count($opts->getOptions()) == 0) {
     echo $opts->getUsageMessage();
     exit(0);
 }
 // Get provided directory if exist
 if (!isset($opts->getRemainingArgs()[0])) {
     $path = '.';
 } else {
     $path = $opts->getRemainingArgs()[0];
 }
 if (!is_dir($path)) {
     $phpooleConsole->wlError('Invalid directory provided!');
     exit(2);
 }
 $websitePath = str_replace(DS, '/', realpath($path));
 // Instanciate the PHPoole API
Example #6
0
    /**
     * Test to ensure that dashed long names will parse correctly
     *
     * @group ZF-4763
     */
    public function testDashWithinLongOptionGetsParsed()
    {
        $opts = new Getopt(
            array( // rules
                'man-bear|m-s' => 'ManBear with dash',
                'man-bear-pig|b=s' => 'ManBearPid with dash',
                ),
            array( // arguments
                '--man-bear-pig=mbp',
                '--man-bear',
                'foobar'
                )
            );

        $opts->parse();
        $this->assertEquals('foobar', $opts->getOption('man-bear'));
        $this->assertEquals('mbp', $opts->getOption('man-bear-pig'));
    }
Example #7
0
        exit(2);
    }
}
$libraryPath = getcwd();
// Setup autoloading
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory', 'append|a' => 'Append to autoload file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file', 'ignore|i-s' => 'Comma-separated namespaces to ignore', 'sort|s' => 'Alphabetically sort classes');
try {
    $opts = new Console\Getopt($rules);
    $opts->parse();
} catch (Console\Exception\RuntimeException $e) {
    echo $e->getUsageMessage();
    exit(2);
}
if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit(0);
}
$ignoreNamespaces = array();
if (isset($opts->i)) {
    $ignoreNamespaces = explode(',', $opts->i);
}
$relativePathForClassmap = '';
if (isset($opts->l)) {
    if (!is_dir($opts->l)) {
        echo 'Invalid library directory provided' . PHP_EOL . PHP_EOL;
        echo $opts->getUsageMessage();
        exit(2);
    }
    $libraryPath = $opts->l;
Example #8
0
$docbookPath = __DIR__ . '/../documentation/manual/en/module_specs';
$docbookFile = false;

// Parse options
try {
    $opts = new Zend\Console\Getopt($rules);
    $opts->parse();
} catch (Zend\Console\Getopt\Exception $e) {
    // Error creating or parsing options; show usage message
    echo $e->getUsageMessage();
    exit(2);
}

// Help requested
if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit();
}

// Were we provided a class name?
if (!isset($opts->c)) {
    // No class name == no execution
    echo "Must provide a class via the -c or --class option\n\n";
    echo $opts->getUsageMessage();
    exit(2);
}
// Valid class name?
$class = $opts->c;
if (!class_exists($class) && !interface_exists($class)) {
    // Invalid class name == no execution
Example #9
0
 /**
  * @param array $argv
  * @throws \Zend\Console\Exception\RuntimeException
  */
 public function parseGetOpt(array $argv)
 {
     $rules = array('h|help' => 'show this help', 'l|lines=i' => 'output the last N lines of a stacktrace. Default: 100', 'line-length=i' => 'maximum length of a line. Default 512', 'process-name=s' => 'name of running php processes. Default: autodetect', 'live' => 'search while running for new upcoming pid\'s', 'o|output=s' => 'output log to file');
     $opts = new Console\Getopt($rules, $argv);
     $opts->parse();
     if ($opts->help) {
         throw new Console\Exception\RuntimeException('', $opts->getUsageMessage());
     }
     if ($opts->getOption('lines')) {
         $this->getStrace()->setLines(min(1000, max(1, $opts->getOption('lines'))));
     }
     if ($opts->getOption('line-length')) {
         $this->getStrace()->setLineLength(min(1 * 1024 * 1024, max(10, $opts->getOption('line-length'))));
     }
     if ($opts->getOption('process-name')) {
         $this->getProcessStatus()->setProcessName($opts->getOption('process-name'));
     }
     if ($opts->getOption('output')) {
         $fileOutput = new FileOutput($opts->getOption('output'));
         $this->getCommandLine()->attachObserver($fileOutput, 'stdout');
         $this->getCommandLine()->attachObserver($fileOutput, 'stderr');
     }
     if ($opts->getOption('live')) {
         $this->setLive(true);
     }
 }
Example #10
0
define('MULTISITE_HOST_BASED', 2);
$baseDir = str_replace('\\', '/', dirname(__FILE__));
$overrideDir = $baseDir . '/local';
$host = $module = '';
$multisiteMode = MULTISITE_NONE;
$basePath = '/vufind';
try {
    $opts = new Getopt(array('use-defaults' => 'Use VuFind Defaults to Configure (ignores any other arguments passed)', 'overridedir=s' => "Where would you like to store your local settings? [{$baseDir}/local]", 'module-name=s' => 'What module name would you like to use? Use disabled, to not use', 'basepath=s' => 'What base path should be used in VuFind\'s URL? [/vufind]', 'multisite-w' => 'Specify we are going to setup a multisite. Options: directory and host', 'hostname=s' => 'Specify the hostname for the VuFind Site, When multisite=host', 'non-interactive' => 'Use settings if provided via arguments, otherwise use defaults'));
    $opts->parse();
} catch (Exception $e) {
    echo $e->getUsageMessage();
    exit;
}
echo "VuFind has been found in {$baseDir}.\n\n";
// Are we allowing user interaction?
$interactive = !$opts->getOption('non-interactive');
$userInputNeeded = array();
// Load user settings if we are not forcing defaults:
if (!$opts->getOption('use-defaults')) {
    if ($opts->getOption('overridedir')) {
        $overrideDir = $opts->getOption('overridedir');
    } else {
        if ($interactive) {
            $userInputNeeded['overrideDir'] = true;
        }
    }
    if ($opts->getOption('module-name')) {
        if ($opts->getOption('module-name') !== 'disabled') {
            $module = $opts->getOption('module-name');
            if (($result = validateModules($module)) !== true) {
                die($result . "\n");
Example #11
0
 /**
  * @see	\wcf\system\cli\command\ICLICommand::execute()
  */
 public function execute(array $parameters)
 {
     $this->argv->setArguments($parameters);
     $this->argv->parse();
     if ($this->argv->list) {
         CLIWCF::getReader()->println(CLIUtil::generateTable($this->generateList()));
         return;
     }
     $args = $this->argv->getRemainingArgs();
     // validate parameters
     if (count($args) != 1) {
         throw new ArgvException('', $this->getUsage());
     }
     $class = $args[0];
     // assume wcf\system\worker when no FQN is given
     if (strpos($class, '\\') === false) {
         $class = 'wcf\\system\\worker\\' . $class;
     }
     $invalid = false;
     if (!class_exists($class)) {
         $invalid = true;
     } else {
         $reflection = new \ReflectionClass($class);
         if (!$reflection->isInstantiable()) {
             $invalid = true;
         } else {
             if (!ClassUtil::isInstanceOf($class, 'wcf\\system\\worker\\IWorker')) {
                 $invalid = true;
             }
         }
     }
     if ($invalid) {
         throw new ArgvException("Invalid worker '" . $class . "' given", $this->getUsage());
     }
     // parse parameters
     $options = $this->argv->getOptions();
     $parameters = array();
     foreach ($options as $option) {
         $value = $this->argv->getOption($option);
         if ($option === 'setParameter') {
             if (!is_array($value)) {
                 $value = array($value);
             }
             foreach ($value as $parameter) {
                 list($parameterKey, $parameterValue) = explode('=', $parameter);
                 $parameters[$parameterKey] = $parameterValue;
             }
         } else {
             $parameters[$option] = $value;
         }
     }
     $worker = new $class($parameters);
     $worker->validate();
     $worker->getProgress();
     // make sure objects are counted
     // initialize progressbar
     $progressbar = new ProgressBar(new ConsoleProgressBar(array('width' => CLIWCF::getTerminal()->getWidth())));
     $progress = 0;
     for ($i = 0; $progress < 100; $i++) {
         $worker->setLoopCount($i);
         $worker->validate();
         // execute worker
         $worker->execute();
         // update progress
         $progress = $worker->getProgress();
         $progressbar->update($progress);
     }
     $progressbar->update($progress);
     $progressbar->getAdapter()->finish();
 }
Example #12
0
}
function exitWithMessage($msg, $help, $code)
{
    title();
    echo $msg . PHP_EOL;
    echo $help;
    exit($code);
}
$rules = array('help|h' => 'Get usage message', 'title|t-s' => 'Document title: default = "Foo"');
try {
    $opts = new Getopt($rules);
    $opts->parse();
} catch (Console\Exception\RuntimeException $e) {
    exitWithMessage($e->getMessage(), $e->getUsageMessage(), 1);
}
if ($opts->getOption('h')) {
    exitWithMessage('tdconv <testdox.html.file.name> <output.file.name>', $opts->getUsageMessage(), 0);
}
$title = false;
$args = $opts->getArguments();
if ($opts->getOption('t')) {
    $title = $opts->getOption('t');
    unset($args['title']);
}
if (count($args) !== 2) {
    exitWithMessage('Expected exactly two arguments, got ' . count($args), $opts->getUsageMessage(), 1000);
}
$testdoxFile = $args[0];
$outputFile = $args[1];
//get the xml translation
$xsldoc = new \DOMDocument();