#!/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')) . '/');
예제 #2
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));