Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     $this->seeder_path = ROOTPATH . '/vendor/kenjis/codeigniter-cli/tests/Fake/seeds/';
     $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 Seed($context, $this->stdio, $ci);
     $this->cmd->setSeederPath($this->seeder_path);
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
#!/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\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>>');
Ejemplo n.º 8
0
} 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());
    Dotenv::required(['DISQUS_API_KEY', 'DISQUS_API_SECRET', 'DISQUS_ACCESS_TOKEN']);
} catch (\RuntimeException $e) {
 public function getStdio(CliFactory $cli)
 {
     return $cli->newStdio();
 }
Ejemplo n.º 10
0
#!/usr/bin/env php
<?php 
require 'vendor/autoload.php';
require "vendor/bolstad/csv-writer/src/CsvWriter/Simple.php";
date_default_timezone_set("Europe/Stockholm");
use CsvParser\Simple;
use Aura\Cli\CliFactory;
use Aura\Cli\Status;
#$csvDumper = new SimpleCsvWrite( 'loggalogga' );
// get the context and stdio objects
$cli_factory = new CliFactory();
$context = $cli_factory->newContext($GLOBALS);
$stdio = $cli_factory->newStdio();
// define options and named arguments through getopt
$options = ['verbose,v,file:,filter'];
$getopt = $context->getopt($options);
print_r($getopt);
function splitArgs($insStr, $key, $value)
{
    $data = split('-', $insStr);
    if (count($data) == 2) {
        print_r($data);
        $ret[$key] = $data[0];
        $ret[$value] = $data[1];
        return $ret;
    } else {
        return;
    }
}
function handler($data)
{