public function fire()
 {
     $timetablePath = $this->argument('timetable-path');
     $memoryUsage = new \stdClass();
     $memoryUsage->start = $this->formatBytes(memory_get_usage());
     $timetable = new Timetable($timetablePath);
     $climate = new \League\CLImate\CLImate();
     $memoryUsage->peak = $this->formatBytes(memory_get_peak_usage());
     $memoryUsage->end = $this->formatBytes(memory_get_usage());
     $climate->out('Stop Points');
     $climate->table($timetable->getStopPoints());
     $climate->border();
     $climate->table($timetable->getRoutes());
     $climate->border();
     $climate->out('Memory Usage');
     $climate->table([$memoryUsage]);
 }
예제 #2
0
define('SECTION', $cli->arguments->get('section'));
if (file_exists(EDGERC) && !is_writable(EDGERC) || !is_writable(HOME)) {
    $cli->to('error')->error("Unable to write to file " . EDGERC);
    exit(-1);
}
echo "After authorizing your client in the {OPEN} API Administration tool,\n";
echo "export the credentials and paste the contents of the export file below,\n";
echo "followed by control-D. (You may need to enter is twice)\n";
echo ">>> ";
$inputStream = fopen('php://stdin', 'r+');
if (!($file = $cli->arguments->get('file'))) {
    $input = stream_get_contents($inputStream);
} elseif (file_exists($file) && is_readable($file)) {
    $input = file_get_contents($file);
}
$cli = new League\CLImate\CLImate();
$cli->out("");
if (file_exists(EDGERC)) {
    $cli->bold()->info("Updating Existing .edgerc File");
    $file = parse_ini_file(EDGERC, true, INI_SCANNER_RAW);
    if (isset($file[SECTION])) {
        $response = $cli->bold()->cyan()->input("Update existing section? (" . SECTION . ") [Y/n]")->prompt();
        if (strtolower($response) != 'y' && !empty($response)) {
            $cli->error("This script will now exit.");
            exit(-1);
        }
    } else {
        $cli->lightBlue("Adding new section: " . SECTION);
    }
} else {
    $cli->info("Creating new .edgerc file");
#!/usr/bin/php
<?php 
require_once 'vendor/autoload.php';
$cli = new League\CLImate\CLImate();
$cli->description('tutodotcom-fetcher is a small program that downloads tuto.com tutorial videos');
$cli->arguments->add(['id' => ['prefix' => 'i', 'longPrefix' => 'id', 'description' => 'The ID(s) of the tuto to download (comma-separated)', 'required' => true], 'user' => ['prefix' => 'u', 'longPrefix' => 'user', 'description' => 'The email address to log in with', 'required' => true], 'password' => ['prefix' => 'p', 'longPrefix' => 'password', 'description' => 'The password to log in with', 'required' => true], 'output' => ['prefix' => 'o', 'longPrefix' => 'output', 'description' => 'The output directory', 'required' => true], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Prints an usage statement', 'noValue' => true]]);
define('PADDING', 60);
$browser_headers = ['User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3'];
// Check: arguments
$arguments_valid = true;
try {
    $cli->arguments->parse();
} catch (Exception $e) {
    $arguments_valid = false;
    if (!$cli->arguments->defined('help')) {
        $cli->red()->error($e->getMessage());
    }
}
if (!$arguments_valid || $cli->arguments->defined('help')) {
    $cli->usage();
    die;
}
// Check: output directory
$cli->inline(str_pad('Output directory exists and is writable', PADDING));
if (!is_dir($cli->arguments->get('output')) || !is_writeable($cli->arguments->get('output'))) {
    $cli->inline('[')->red()->inline('FAIL')->white()->out(']');
    $cli->red()->out('Please choose a writable directory!');
    die;
}
$cli->inline('[ ')->green()->inline('OK')->white()->out(' ]');
define('OUTPUT_DIR', realpath($cli->arguments->get('output')) . '/');
예제 #4
0
<?php

# This file is _only_ used to setup and run these command line examples.
include __DIR__ . '/composer.php';
$cli = new League\CLImate\CLImate();
$cli->arguments->add(['debug' => ['prefix' => 'd', 'longPrefix' => 'debug', 'description' => 'Enable Debug Mode: Output HTTP traffic to STDOUT', 'defaultValue' => false, 'noValue' => true], 'verbose' => ['prefix' => 'v', 'longPrefix' => 'verbose', 'description' => 'Enable Verbose Mode: Output response bodies (JSON) to STDOUT', 'defaultValue' => false, 'noValue' => true], 'file' => ['prefix' => 'e', 'longPrefix' => 'edgerc', 'description' => 'Path to .edgerc file', 'defaultValue' => null], 'section' => ['prefix' => 's', 'longPrefix' => 'section', 'description' => '.edgerc section to use', 'defaultValue' => 'default'], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Show this help', 'defaultValue' => false, 'noValue' => true]]);
$cli->arguments->parse($_SERVER['argv']);
if ($cli->arguments->get('help')) {
    $cli->usage();
    exit;
}
if ($cli->arguments->get('debug')) {
    \Akamai\Open\EdgeGrid\Client::setDebug(true);
}
if ($cli->arguments->get('verbose')) {
    \Akamai\Open\EdgeGrid\Client::setVerbose(true);
}
$configFile = $cli->arguments->get('config');
$configSection = $cli->arguments->get('section');
if (!extension_loaded('curl')) {
    $cli->whisper("PHP curl extension not enabled. Output from --debug may be less useful.");
}
예제 #5
0
define('DB_USER', 'login');
// Connection password
define('DB_PASS', 'password');
// Database name for "Information Schema", if there's a name change, in the future
define('INFO_SCHEMA', 'information_schema');
// Name of the field identifying a group
define('SEARCHED_FIELD', 'gid');
// CSV File containing the groups oldname / newname pairs
define('CSV_FILE', './test_csv.csv');
// log file
define('LOGFILE', '/tmp/renameGroups.log');
/******* END CONF *********************/
require_once 'vendor/autoload.php';
use League\Csv\Reader;
/******* MAIN *********************/
$climate = new League\CLImate\CLImate();
$climate->green()->out('RenameGroups launched');
$logger = new Logger(LOGFILE);
$gr = new GroupRenamer();
// comment if you don't want complete log (only exceptions will be logged)
$gr->setLogger($logger);
$gr->setCli($climate);
try {
    $gr->run();
} catch (Exception $e) {
    $climate->red()->out('ERROR ! ' . $e->getMessage());
    $logger->put($e->getMessage());
}
$climate->green()->out('END');
/******* END MAIN *********************/
class GroupRenamer
예제 #6
0
<?php

require_once 'vendor/autoload.php';
use Exercise\TravelersRepository;
$climate = new League\CLImate\CLImate();
$climate->clear();
$climate->red('Hello. This is SQL exercise script.');
$travelersRepo = new TravelersRepository();
$climate->table($travelersRepo->getAllTravelersWithDestinations());
$climate->table($travelersRepo->getTravelersByDestinations(array('Cuba', 'Sochi')));
$climate->table($travelersRepo->getTravelersByDestinations(array('Cuba', 'Sochi'), true));
예제 #7
0
include('libraries/fields/corefields.php');
include('libraries/forms/coreforms.php');
*/
I18n::load_lang('common');
//Load extra libraries
/*Utils::load_libraries(array('fields/corefields'));
Utils::load_libraries(array('forms/coreforms'));*/
//date_default_timezone_set (MY_TIMEZONE);
$utility_console = 1;
//load_lang('common', 'user');
$model = array();
//Check arguments
define('OPTS', 'm:c:');
$longopts = array();
$options = getopt(OPTS, $longopts);
$climate = new League\CLImate\CLImate();
if (!isset($options['m']) && !isset($options['c'])) {
    //die("Use: php console.php -m=module -c=console_controller [more arguments for daemon]\n");
    $climate->white()->backgroundBlack()->out("Use: php console.php -m=group/module -c=console_controller [more arguments for daemon]");
    die;
}
$module = @Utils::form_text($options['m']);
$console_controller = @Utils::form_text(basename($options['c']));
//Include console_controller
$controller = __DIR__ . '/vendor/' . $module . '/console/controller_' . $console_controller . '.php';
\PhangoApp\PhaView\View::$folder_env[] = 'vendor/' . $module . '/views';
if (file_exists($controller)) {
    include $controller;
    $script_base_controller = $module;
    $function_console = $console_controller . 'Console';
    if (function_exists($function_console)) {
예제 #8
0
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
use Pod\Slack\Api;
$dotenv = new Dotenv\Dotenv(getenv('HOME'), '.slackbot');
$dotenv->load();
$dotenv->required('SLACKBOT_TOKEN');
$climate = new League\CLImate\CLImate();
$climate->arguments->add(['help' => ['longPrefix' => 'help', 'description' => 'Prints a usage statement', 'noValue' => true], 'name' => ['description' => 'Name or real name to send message to', 'required' => true], 'message' => ['description' => 'message to send', 'required' => true]]);
$climate->arguments->parse();
if ($climate->arguments->defined('help')) {
    $climate->usage();
    exit;
}
$name = $climate->arguments->get('name');
$message = $climate->arguments->get('message');
$token = getenv('SLACKBOT_TOKEN');
$api = new Api\Api($token);
$auth = $api->auth->test();
$bot = $api->users->info($auth->user_id);
$ul = $api->users->list();
$user = $ul->findByNameOrRealName($name);
if ($user === null) {
    echo "No such user" . PHP_EOL;
    exit(1);
}
$api->chat->postMessage($user->id, $message, $bot->name, $bot->profile->image_48);
예제 #9
0
<?php

# This file is _only_ used to setup and run these command line examples.
include __DIR__ . '/composer.php';
$cli = new League\CLImate\CLImate();
$defaultArgs = ['debug' => ['prefix' => 'd', 'longPrefix' => 'debug', 'description' => 'Enable Debug Mode: Output HTTP traffic to STDOUT', 'defaultValue' => false, 'noValue' => true], 'verbose' => ['prefix' => 'v', 'longPrefix' => 'verbose', 'description' => 'Enable Verbose Mode: Output response bodies (JSON) to STDOUT', 'defaultValue' => false, 'noValue' => true], 'file' => ['prefix' => 'e', 'longPrefix' => 'edgerc', 'description' => 'Path to .edgerc file', 'defaultValue' => null], 'section' => ['prefix' => 's', 'longPrefix' => 'section', 'description' => '.edgerc section to use', 'defaultValue' => 'default'], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Show this help', 'defaultValue' => false, 'noValue' => true]];
$arguments = isset($arguments) ? array_merge($defaultArgs, $arguments) : $defaultArgs;
try {
    $cli->arguments->add($arguments);
    $cli->arguments->parse($_SERVER['argv']);
    if ($cli->arguments->get('help')) {
        $cli->usage();
        exit;
    }
    if ($cli->arguments->get('debug')) {
        \Akamai\Open\EdgeGrid\Client::setDebug(true);
    }
    if ($cli->arguments->get('verbose')) {
        \Akamai\Open\EdgeGrid\Client::setVerbose(true);
    }
    $configFile = $cli->arguments->get('config');
    $configSection = $cli->arguments->get('section');
    if (!extension_loaded('curl')) {
        $cli->whisper("PHP curl extension not enabled. Output from --debug may be less useful.");
    }
} catch (\Exception $e) {
    $cli->error($e->getMessage() . "\n");
    $cli->usage();
    exit;
}
예제 #10
0
<?php

require_once 'vendor/autoload.php';
$climate = new League\CLImate\CLImate();
$climate->arguments->add(['percent' => ['prefix' => 'p', 'longPrefix' => 'percent', 'description' => 'Percent level for creation image.', 'defaultValue' => '0']]);
// Clearing all output dir before launch script.
exec('rm -rf ./images/output');
if (!is_dir("./images")) {
    $climate->error("Tags don't exist.");
    $climate->Green("Please create it using: casperjs compare.js --tag=[TAG] --domain=[DOMAIN]");
    return;
} else {
    do {
        $tags = scandir("./images");
        unset($tags[0]);
        unset($tags[1]);
        $input = $climate->checkboxes('Please choose 2 tags for comparing:', $tags);
        $response = $input->prompt();
        if (count($response) != 2) {
            $climate->error('You need to choice 2 options.');
        }
    } while (count($response) != 2);
}
$tag_one = $response[0];
$tag_two = $response[1];
if (!is_dir("./images/{$tag_one}")) {
    $climate->error('Tag one is required.');
    $climate->usage();
    return;
}
if (!is_dir("./images/{$tag_two}")) {
예제 #11
0
<?php

require_once 'vendor/autoload.php';
use Exercise\Helpers\StringHelper;
$climate = new League\CLImate\CLImate();
$climate->description("This is php exercise test script");
$climate->arguments->add(['string' => ['prefix' => 's', 'description' => 'Input string for processing', 'required' => true]]);
if (!$climate->arguments->defined("string")) {
    $climate->usage();
    exit;
}
$climate->arguments->parse();
$inputString = $climate->arguments->get("string");
$climate->clear();
$climate->red('Hello. This is php exercise script.');
$climate->green()->inline("Input string: ")->white($inputString);
$stringHelper = new StringHelper();
$climate->green()->inline("Out string: ")->white($stringHelper->revertAndExcludeVowels($inputString));
예제 #12
0
파일: publish.php 프로젝트: grynn/git
 *   composer must be in path
 *   git must be in path
 *   $PROJECT_ROOT/composer.json must exist
 *   $PROJECT_ROOT/{logs,test,web} must exist
 *   $PROJECT_ROOT/deploy.sh must exist (this will be executed on the remote)
 *   $PROJECT_ROOT/
 *
 * Copyright (c) 2015-2016, Vishal Doshi <*****@*****.**>.
 * All rights reserved.
 */
namespace Grynn;

require_once __DIR__ . "/vendor/autoload.php";
use CommandLine;
$st = microtime(true);
$climate = new \League\CLImate\CLImate();
$defaults = ['remote' => 'origin'];
//Parse command line
$opt = parseCommandLine($argv);
if (isset($opt['remote'])) {
    $remote = $opt['remote'];
} else {
    $remote = $defaults['remote'];
}
//Get project root (root of git && has composer.json)
$climate->inline("Detecting project root: ");
$git = new Git();
$root = $git->getRoot();
if (!file_exists($root . "/composer.json")) {
    errExit($climate, "Could not find composer.json! in {$root}");
    die;
예제 #13
0
<?php

require_once 'vendor/autoload.php';
$climate = new League\CLImate\CLImate();
for ($year = 2012; $year <= 2016; $year++) {
    $climate->flank($year);
    file_put_contents(__DIR__ . '/sitemap-' . $year . '.txt.gz', '');
    $json = json_decode(file_get_contents(__DIR__ . '/vendor/infogreffe/entreprises-immatriculees-en-' . $year . '/download'));
    if ($gzfile = gzopen(__DIR__ . '/sitemap-' . $year . '.txt.gz', 'w')) {
        $progress = $climate->progress()->total(count($json));
        foreach ($json as $i => $company) {
            if (isset($company->fields->siren)) {
                gzwrite($gzfile, 'https://ess.netlib.re/company/' . $company->fields->siren . PHP_EOL);
            }
            $progress->current($i);
        }
        gzclose($gzfile);
    }
}
예제 #14
0
파일: eden.php 프로젝트: JordanRL/eden
<?php

$basepath = realpath(__DIR__ . '/../');
require_once $basepath . '/vendor/autoload.php';
$cli = new \League\CLImate\CLImate();
mkdir($basepath . '/logs');
mkdir($basepath . '/cache');
$cli->out('Initialized.');