diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 92754bc..d77444f 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -23,27 +23,16 @@ if(isset($args['no-banner']) == false) { + $basic_ascii = false; + if(isset($args['basic-ascii'])) { - $banner = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'banner_basic'); - } - else - { - $banner = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'banner_extended'); + $basic_ascii = true; } - $banner_version = NCC_VERSION_BRANCH . ' ' . NCC_VERSION_NUMBER; - $banner_version = str_pad($banner_version, 21); - - $banner_copyright = 'Copyright (c) 2022-2022 Nosial'; - $banner_copyright = str_pad($banner_copyright, 30); - - $banner = str_ireplace('%A', $banner_version, $banner); - $banner = str_ireplace('%B', $banner_copyright, $banner); - - print($banner . PHP_EOL); + // TODO: Make copyright not hard-coded. + print(\ncc\Utilities\Functions::getBanner(NCC_VERSION_BRANCH . ' ' . NCC_VERSION_NUMBER, 'Copyright (c) 2022-2022 Nosial', $basic_ascii) . PHP_EOL); } - switch(strtolower($args['ncc-cli'])) { diff --git a/src/ncc/Utilities/Functions.php b/src/ncc/Utilities/Functions.php index b391bb6..4a39da0 100644 --- a/src/ncc/Utilities/Functions.php +++ b/src/ncc/Utilities/Functions.php @@ -152,4 +152,33 @@ return $current_count; } + + /** + * Returns the banner for the CLI menu (Really fancy stuff!) + * + * @param string $version + * @param string $copyright + * @param bool $basic_ascii + * @return string + */ + public static function getBanner(string $version, string $copyright, bool $basic_ascii=false): string + { + if($basic_ascii) + { + $banner = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'banner_basic'); + } + else + { + $banner = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'banner_extended'); + } + + $banner_version = str_pad($version, 21); + $banner_copyright = str_pad($copyright, 30); + + $banner = str_ireplace('%A', $banner_version, $banner); + /** @noinspection PhpUnnecessaryLocalVariableInspection */ + $banner = str_ireplace('%B', $banner_copyright, $banner); + + return $banner; + } } \ No newline at end of file