From 6a399261a8c44d51883cae0a217336b184f76ce4 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 24 May 2022 19:05:40 -0400 Subject: [PATCH] Added basic menu for credential menu --- src/ncc/CLI/CredentialMenu.php | 71 ++++++++++++++++++++++++++++++++ src/ncc/CLI/HelpMenu.php | 14 ++++++- src/ncc/CLI/Main.php | 40 +++++++++--------- src/ncc/CLI/VaultMenu.php | 8 ---- src/ncc/Objects/Vault.php | 10 +++++ src/ncc/Utilities/Functions.php | 34 +++++++++++++++ src/ncc/Utilities/PathFinder.php | 1 + src/ncc/autoload.php | 1 + 8 files changed, 150 insertions(+), 29 deletions(-) create mode 100644 src/ncc/CLI/CredentialMenu.php delete mode 100644 src/ncc/CLI/VaultMenu.php create mode 100644 src/ncc/Objects/Vault.php diff --git a/src/ncc/CLI/CredentialMenu.php b/src/ncc/CLI/CredentialMenu.php new file mode 100644 index 0000000..0732752 --- /dev/null +++ b/src/ncc/CLI/CredentialMenu.php @@ -0,0 +1,71 @@ +toString($options_padding) . PHP_EOL); + } + print(PHP_EOL); + } + } \ No newline at end of file diff --git a/src/ncc/CLI/HelpMenu.php b/src/ncc/CLI/HelpMenu.php index e0f56a8..b756d22 100644 --- a/src/ncc/CLI/HelpMenu.php +++ b/src/ncc/CLI/HelpMenu.php @@ -9,11 +9,21 @@ /** * Displays the main help menu * - * @param $argv + * @param $args * @return void */ - public static function start($argv) + public static function start($args) { + $basic_ascii = false; + + if(isset($args['basic-ascii'])) + { + $basic_ascii = true; + } + + // 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); + print('Usage: ncc COMMAND [options]' . PHP_EOL); print('Alternative Usage: ncc.php --ncc-cli=COMMAND [options]' . PHP_EOL . PHP_EOL); print('Nosial Code Compiler / Project Toolkit' . PHP_EOL . PHP_EOL); diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index d77444f..174de8b 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -2,6 +2,8 @@ namespace ncc\CLI; + use Exception; + use ncc\ncc; use ncc\Utilities\Resolver; class Main @@ -19,32 +21,32 @@ if(isset($args['ncc-cli'])) { // Initialize NCC - \ncc\ncc::initialize(); + ncc::initialize(); - if(isset($args['no-banner']) == false) + try { - $basic_ascii = false; - - if(isset($args['basic-ascii'])) + switch(strtolower($args['ncc-cli'])) { - $basic_ascii = true; + default: + print('Unknown command ' . strtolower($args['ncc-cli']) . PHP_EOL); + exit(1); + + case 'credential': + CredentialMenu::start($args); + exit(0); + + case '1': + case 'help': + HelpMenu::start($args); + exit(0); } - - // 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'])) + catch(Exception $e) { - default: - print('Unknown command ' . strtolower($args['ncc-cli']) . PHP_EOL); - exit(1); - - case '1': - case 'help': - HelpMenu::start($argv); - exit(0); + print('Error: ' . $e->getMessage() . ' (Code: ' . $e->getCode() . ')' . PHP_EOL); + exit(1); } + } } diff --git a/src/ncc/CLI/VaultMenu.php b/src/ncc/CLI/VaultMenu.php deleted file mode 100644 index 6797ff5..0000000 --- a/src/ncc/CLI/VaultMenu.php +++ /dev/null @@ -1,8 +0,0 @@ - '/Abstracts/RegexPatterns.php', 'ncc\\abstracts\\scopes' => '/Abstracts/Scopes.php', 'ncc\\abstracts\\stringpaddingmethod' => '/Abstracts/StringPaddingMethod.php', + 'ncc\\cli\\credentialmenu' => '/CLI/CredentialMenu.php', 'ncc\\cli\\functions' => '/CLI/Functions.php', 'ncc\\cli\\helpmenu' => '/CLI/HelpMenu.php', 'ncc\\cli\\main' => '/CLI/Main.php',