From 6381ec509c30cfed3f8b3a9bc38e1d9a85df33cc Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 7 Feb 2023 16:07:52 -0500 Subject: [PATCH] Minor improvements to the CLI interface including fixing `--version` --- CHANGELOG.md | 1 + src/ncc/CLI/HelpMenu.php | 6 ++++-- src/ncc/CLI/Main.php | 13 ++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd8940..cd376f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bug fix where resources are not decoded correctly when installing packages [#31](https://git.n64.cc/nosial/ncc/-/issues/42) - Fixed issue where dependency conflicts are thrown even when `--reinstall` is used - Properly implemented `composer.enable_internal_composer` so that warnings regarding improper configuration values are not thrown +- Minor improvements to the CLI interface including fixing `--version` ### Changed diff --git a/src/ncc/CLI/HelpMenu.php b/src/ncc/CLI/HelpMenu.php index 8381429..e6ce060 100644 --- a/src/ncc/CLI/HelpMenu.php +++ b/src/ncc/CLI/HelpMenu.php @@ -49,8 +49,10 @@ namespace ncc\CLI; $basic_ascii = true; } - // TODO: Make copyright not hard-coded. - print(Functions::getBanner(NCC_VERSION_BRANCH . ' ' . NCC_VERSION_NUMBER, 'Copyright (c) 2022-2022 Nosial', $basic_ascii) . PHP_EOL); + Console::out(Functions::getBanner( + sprintf('%s %s', NCC_VERSION_BRANCH, NCC_VERSION_NUMBER), + sprintf('Copyright (c) 2022-%s Nosial', date('Y')), $basic_ascii) + ); Console::out('Usage: ncc COMMAND [options]'); Console::out('Alternative Usage: ncc.php --ncc-cli=COMMAND [options]' . PHP_EOL); diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 5ce5ad0..525b5df 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -125,6 +125,12 @@ Console::outWarning('This is an unstable build of NCC, expect some features to not work as expected'); } + if(isset(self::$args['version'])) + { + self::displayVersion(); + exit(0); + } + try { switch(strtolower(self::$args['ncc-cli'])) @@ -162,7 +168,7 @@ break; case 'version': - Console::out(sprintf('NCC version %s (%s)', NCC_VERSION_NUMBER, NCC_VERSION_BRANCH)); + self::displayVersion(); break; case '1': @@ -181,6 +187,11 @@ } } + private static function displayVersion() + { + Console::out(sprintf('NCC version %s (%s)', NCC_VERSION_NUMBER, NCC_VERSION_BRANCH)); + } + /** * @return array */