public function __construct($version) { $this->version = $version; $cliFactory = new CliFactory(); $this->context = $cliFactory->newContext($GLOBALS); $this->stdio = new \nochso\Phormat\CLI\Stdio(new Handle('php://stdin', 'r'), new Handle('php://stdout', 'w+'), new Handle('php://stderr', 'w+'), new Formatter()); $this->opt = $this->context->getopt($this->getOptions()); }
public function setUp() { $ci =& get_instance(); $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $this->stdio = $cli_factory->newStdio('php://memory', 'php://memory', 'php://memory'); $this->stdout = $this->stdio->getStdout(); $this->stderr = $this->stdio->getStderr(); $this->cmd = new Run($context, $this->stdio, $ci); }
public function setUp() { $this->ci =& get_instance(); $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $this->stdio = $cli_factory->newStdio('php://memory', 'php://memory', 'php://memory'); $this->stdout = $this->stdio->getStdout(); $this->stderr = $this->stdio->getStderr(); $this->cmd = new Migrate($context, $this->stdio, $this->ci); $this->ci->config->set_item('migration_version', 20150429110003); }
public function setUp() { $this->ci =& get_instance(); $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $this->stdio = $cli_factory->newStdio('php://memory', 'php://memory', 'php://memory'); $this->stdout = $this->stdio->getStdout(); $this->stderr = $this->stdio->getStderr(); $this->cmd = new Generate($context, $this->stdio, $this->ci); $this->migration_path = __DIR__ . '/../Fake/migrations/'; foreach (glob($this->migration_path . '*_Test_of_generate_migration.php') as $file) { unlink($file); } }
public function __construct(array $globals = null) { $this->version = new VersionInfo('writeme', '0.1.0', '<<green>>%s<<reset>> <<yellow>>%s<<reset>>'); $clif = new CliFactory(); if ($globals === null) { $globals = $GLOBALS; } $this->context = $clif->newContext($globals); $this->stdio = Stdio::create(); $this->placeholders = new PlaceholderCollection([new Frontmatter(), new TOC(), new API(), new Changelog(), new Badge()]); $placeholderDocs = new PlaceholderDocs(); $placeholderDocs->setPlaceholderCollection($this->placeholders); $this->placeholders->add($placeholderDocs); $this->converter = new Converter(); }
public function getParams() { $params = new \StdClass(); $cliFactory = new CliFactory(); $context = $cliFactory->newContext($GLOBALS); $stdio = $cliFactory->newStdio(); $getopt = $context->getopt(['server1::', 'server2::', 'format::', 'template::', 'type::', 'include::', 'nocomments::', 'config::', 'output::', 'debug::', 'silent::']); $input = $getopt->get(1); if ($input) { $params->input = $this->parseInput($input); } else { throw new CLIException("Missing input"); } if ($getopt->get('--server1')) { $params->server1 = $this->parseServer($getopt->get('--server1')); } if ($getopt->get('--server2')) { $params->server2 = $this->parseServer($getopt->get('--server2')); } if ($getopt->get('--format')) { $params->format = $getopt->get('--format'); } if ($getopt->get('--template')) { $params->template = $getopt->get('--template'); } if ($getopt->get('--type')) { $params->type = $getopt->get('--type'); } if ($getopt->get('--include')) { $params->include = $getopt->get('--include'); } if ($getopt->get('--nocomments')) { $params->nocomments = $getopt->get('--nocomments'); } if ($getopt->get('--config')) { $params->config = $getopt->get('--config'); } if ($getopt->get('--output')) { $params->output = $getopt->get('--output'); } if ($getopt->get('--debug')) { $params->debug = $getopt->get('--debug'); } if ($getopt->get('--silent')) { $params->silent = $getopt->get('--silent'); } return $params; }
public function test_seed_list() { $GLOBALS['argv'][1] = 'seed'; $GLOBALS['argv'][2] = '-l'; $GLOBALS['argc'] = 3; $ci =& get_instance(); $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $this->cmd = new Seed($context, $this->stdio, $ci); $this->cmd->setSeederPath($this->seeder_path); $status = $this->cmd->__invoke(); $this->assertEquals(Status::SUCCESS, $status); $this->stdout->rewind(); $actual = $this->stdout->fread(); $this->assertContains('Table1Seeder', $actual); $this->assertContains('Table2Seeder', $actual); }
#!/usr/bin/env php <?php namespace compwright\DisqusDemo; require_once 'bootstrap.php'; use compwright\Disguz\Disguz; use Guzzle\Http\Exception\HttpException; use Aura\Cli\CliFactory; use Aura\Cli\Status; use Memcache; $factory = new CliFactory(); $stdio = $factory->newStdio(); // Create a client and pass an array of configuration data $client = Disguz::factory(['disqus.keys' => ['api_key' => getenv('DISQUS_API_KEY')]]); // Connect to burst cache $memcache = new Memcache(); list($host, $port) = explode(':', getenv('MEMCACHED')); $connected = $memcache->connect($host, $port); if (!$connected) { throw new \Exception('Unable to connect to Memcache server, ' . getenv('MEMCACHED')); } $forum = getenv('DISQUS_FORUM'); $ttl = getenv('CACHE_TTL'); $healthyKey = getenv('CACHE_NAMESPACE') . '-healthy'; try { // Ping the Disqus API $client->threadsList(compact('forum')); // Save healthy status in burst cache $memcache->set($healthyKey, 'healthy', 0, $ttl); // Report status to the console $stdio->outln('healthy');
<?php use Aura\Cli\CliFactory; use Matthias\SphinxDocumentation\ServiceContainer; $autoloadFile = array_filter(array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'), 'file_exists'); if ($autoloadFile === null) { throw new \RuntimeException('Could not locate the Composer autoload file'); } require reset($autoloadFile); $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $getopt = $context->getopt(array('library-dir*:', 'project-dir:')); $projectDirectory = $getopt->get('--project-dir', getcwd()); $buildDirectory = $getopt->get(1); $libraryDirectories = $getopt->get('--library-dir'); $serviceContainer = new ServiceContainer($projectDirectory, $buildDirectory, $libraryDirectories, true); $serviceContainer->getCollector()->collect();
<?php use Aura\Cli\CliFactory; use Matthias\LeanpubSampler\SampleTextFileGenerator; $autoloadFile = array_filter(array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'), 'file_exists'); if ($autoloadFile === null) { throw new \RuntimeException('Could not locate the Composer autoload file'); } require reset($autoloadFile); $cliFactory = new CliFactory(); $context = $cliFactory->newContext($GLOBALS); $stdio = $cliFactory->newStdio(); $options = array('dir:', 'file:', 'all-sections,s'); $getopt = $context->getopt($options); $manuscriptDirectory = $getopt->get('--dir', 'manuscript/'); $stdio->outln('Look for manuscript files in: <<yellow>>' . $manuscriptDirectory . '<<reset>>'); $file = $getopt->get('--file', 'manuscript/sample-text.txt'); $stdio->outln('Write sample text to: <<yellow>>' . $file . '<<reset>>'); $addAllSectionMarkers = $getopt->get('--all-sections'); $stdio->outln('Add all section markers? <<yellow>>' . ($addAllSectionMarkers ? 'yes' : 'no') . '<<reset>>'); $sampleTextFileGenerator = new SampleTextFileGenerator($manuscriptDirectory, $file, $addAllSectionMarkers); $sampleTextFileGenerator->generate(); $stdio->outln('<<green>>Done!<<reset>>');
$basedir = getcwd(); require_once 'vendor/autoload.php'; } else { fwrite(STDERR, 'Could not find the vendor/autoload.php file' . PHP_EOL); exit(1); } use Aura\Cli\CliFactory; use Aura\Cli\Status; use Aura\Cli\Help; use Aura\Cli\Context\GetoptParser; use Aura\Cli\Context\OptionFactory; use Dotenv; use DisqusAPI; use DisqusInterfaceNotDefined; // Aura CLI library dependencies $auraCli = new CliFactory(); $context = $auraCli->newContext($_SERVER); $stdio = $auraCli->newStdio(); // Assemble the script usage instructions $help = new Help(new OptionFactory()); $help->setSummary('A lightweight command line client for the Disqus API'); $help->setUsage("<resource> <verb> [optionlist]"); $help->setDescr('For a full list of Disqus API resources, verbs, and options, visit https://disqus.com/api/docs'); $help->setOptions($options); // Parse the command line $optionsParser = new GetoptParser(new OptionFactory()); $optionsParser->setOptions($options); $optionsParser->parseInput($context->argv->get()); try { // Load the configuration .env file Dotenv::load(getcwd());
public function getContext(CliFactory $cli) { return $cli->newContext($GLOBALS); }
<?php /** * Builds static pages from README and code samples. */ use Aura\Cli\CliFactory; require_once 'vendor/autoload.php'; //cli setup $factory = new CliFactory(); $cli = $factory->newContext($GLOBALS); $io = $factory->newStdio(); $getop = $cli->getopt(['b,build:', 'p,path:', 'e,env:']); //config $buildDir = $getop->get('--build', __DIR__ . '/_build'); $webPath = $getop->get('--path', '/Quickstarts'); $environment = $getop->get('--env', 'development'); //markdown $io->out('setting up markdown...'); $env = \League\CommonMark\Environment::createCommonMarkEnvironment(); $exampleParser = new ExampleParser(); $exampleRenderer = new ExampleRenderer(); $linkRenderer = new LinkRenderer(['nexmo.github.io', 'nexmo.com', 'docs.nexmo.com', 'dashboard.nexmo.com', 'help.nexmo.com']); $io->out('adding custom parsers/renderers...'); $env->addBlockParser($exampleParser); $env->addBlockRenderer('ExampleElement', $exampleRenderer); $env->addInlineRenderer('League\\CommonMark\\Inline\\Element\\Link', $linkRenderer); $parser = new \League\CommonMark\DocParser($env); $renderer = new \League\CommonMark\HtmlRenderer($env); $io->outln('done'); //mustache $io->out('setting up mustache template loader...');