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]); }
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"); $cli->lightBlue("Adding new section: " . SECTION);
if (1 === count($chapters_uid)) { $cli->inline(str_pad('[' . $input_id . '] ' . $tutorial_title, PADDING)); $chapter_uid = array_keys($chapters_uid)[0]; $chapter_title = !empty(array_values($chapters_uid)[0]) ? array_values($chapters_uid)[0] : $tutorial_title_sanitized; if (empty($tutorial_playlist->{$chapter_uid}->urls->hls)) { $cli->inline('[')->red()->inline('FAIL')->white()->out(']'); continue 1; } $result_hls = exec('./hls-fetch -f --playlist ' . escapeshellarg($tutorial_playlist->{$chapter_uid}->urls->hls) . ' --output=' . escapeshellarg(OUTPUT_DIR . $chapter_title . '.ts')); if (preg_match('/\\d+\\/\\d+/', $result_hls)) { $cli->inline('[ ')->green()->inline('OK')->white()->out(' ]'); } else { $cli->inline('[')->red()->inline('FAIL')->white()->out(']'); } } else { $cli->out('[' . $input_id . '] ' . $tutorial_title . ' (' . count($chapters_uid) . ' chapters)'); is_dir(OUTPUT_DIR . $tutorial_title_sanitized) || mkdir(OUTPUT_DIR . $tutorial_title_sanitized); $j = 0; foreach ($chapters_uid as $chapter_uid => $chapter_title) { ++$j; $cli->inline(str_pad(' - ' . $chapter_title, PADDING)); if (empty($tutorial_playlist->{$chapter_uid}->urls->hls)) { $cli->inline('[')->red()->inline('FAIL')->white()->out(']'); continue 1; } $result_hls = exec('./hls-fetch -f --playlist ' . escapeshellarg($tutorial_playlist->{$chapter_uid}->urls->hls) . ' --output=' . escapeshellarg(OUTPUT_DIR . $tutorial_title_sanitized . '/' . $j . '-' . $chapter_title . '.ts')); if (preg_match('/\\d+\\/\\d+/', $result_hls)) { $cli->inline('[ ')->green()->inline('OK')->white()->out(' ]'); } else { $cli->inline('[')->red()->inline('FAIL')->white()->out(']'); }
<?php $basepath = realpath(__DIR__ . '/../'); require_once $basepath . '/vendor/autoload.php'; $cli = new \League\CLImate\CLImate(); mkdir($basepath . '/logs'); mkdir($basepath . '/cache'); $cli->out('Initialized.');