d06249aecd
These changes are mostly in underlying libraries; however, this now uses the [inspired by F#](https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp) library to handle the feed parsing pipeline and optional return values Reviewed-on: #26
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Command Line Utility Start Script
|
|
*
|
|
* This loads the environment needed for a command line utility
|
|
*
|
|
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
|
* @license MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require 'app-config.php';
|
|
|
|
if (php_sapi_name() != 'cli') {
|
|
http_response_code(404);
|
|
die('Not Found');
|
|
}
|
|
|
|
/**
|
|
* Print a line with a newline character at the end (printf + newline = printfn; surprised this isn't built in!)
|
|
*
|
|
* @param string $format The format string
|
|
* @param mixed ...$values The values for the placeholders in the string
|
|
*/
|
|
function printfn(string $format, mixed ...$values): void
|
|
{
|
|
printf($format . PHP_EOL, ...$values);
|
|
}
|
|
|
|
/**
|
|
* Display a title for a CLI run
|
|
*
|
|
* @param string $title The title to display on the command line
|
|
*/
|
|
function cli_title(string $title): void
|
|
{
|
|
$appTitle = 'Feed Reader Central ~ ' . display_version();
|
|
$dashes = ' +' . str_repeat('-', strlen($title) + 2) . '+' . str_repeat('-', strlen($appTitle) + 2) . '+';
|
|
printfn($dashes);
|
|
printfn(' | %s | %s |', $title, $appTitle);
|
|
printfn($dashes . PHP_EOL);
|
|
}
|