diff --git a/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp b/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp index bd00fb9e38..47c8e0166f 100644 --- a/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp +++ b/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp @@ -22,6 +22,10 @@ #include +#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) +#include +#endif + #include #include #include @@ -32,6 +36,14 @@ #include #include +#define CLI_BOX_TL "\t┌" +#define CLI_BOX_TR "┐" +#define CLI_BOX_BL "\t└" +#define CLI_BOX_BR "┘" +#define CLI_BOX_H "────────────────────────────────────────────────────────────────────────────────────────" +#define CLI_BOX_V "\t│" +#define CLI_BOX_VR "│" + /* Error messages */ #define LOAD_ERROR "Failed to load a script" #define INSPECT_ERROR "Failed to inspect MetaCall context" @@ -453,6 +465,12 @@ void *help(size_t argc, void *args[], void *data) /* Validate function parameters */ EXTENSION_FUNCTION_CHECK(HELP_ERROR); +#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) + /* Enable UTF-8 output so Unicode box-drawing characters render correctly */ + UINT prev_cp = GetConsoleOutputCP(); + SetConsoleOutputCP(CP_UTF8); +#endif + /* Print copyright first */ COPYRIGHT_PRINT(); @@ -462,180 +480,185 @@ void *help(size_t argc, void *args[], void *data) << std::endl; /* Load command */ - std::cout << "\t┌────────────────────────────────────────────────────────────────────────────────────────┐" << std::endl; - std::cout << "\t│ Load a script from file into MetaCall │" << std::endl; - std::cout << "\t│────────────────────────────────────────────────────────────────────────────────────────│" << std::endl; - std::cout << "\t│ Usage: │" << std::endl; - std::cout << "\t│ load ... │" << std::endl; - std::cout << "\t│ : identifier to the type of script │" << std::endl; - std::cout << "\t│ options : │" << std::endl; - std::cout << "\t│ mock - Mock (for testing purposes) │" << std::endl; - std::cout << "\t│ py - Python │" << std::endl; - std::cout << "\t│ node - NodeJS │" << std::endl; - std::cout << "\t│ rb - Ruby │" << std::endl; - std::cout << "\t│ cs - C# NetCore │" << std::endl; - std::cout << "\t│ cob - Cobol │" << std::endl; - std::cout << "\t│ ts - TypeScript │" << std::endl; - std::cout << "\t│ js - V8 JavaScript Engine │" << std::endl; - std::cout << "\t│ file - Files (for handling file systems) │" << std::endl; - std::cout << "\t│ ... : relative or absolute path to the script(s) │" << std::endl; - std::cout << "\t│ │" << std::endl; - std::cout << "\t│ Example: │" << std::endl; - std::cout << "\t│ load node concat.js │" << std::endl; - std::cout << "\t│ load py example.py │" << std::endl; - std::cout << "\t│ load rb hello.rb │" << std::endl; - std::cout << "\t│ │" << std::endl; - std::cout << "\t│ Result: │" << std::endl; - std::cout << "\t│ Script (concat.js) loaded correctly │" << std::endl; - std::cout << "\t└────────────────────────────────────────────────────────────────────────────────────────┘" << std::endl + std::cout << CLI_BOX_TL << CLI_BOX_H << CLI_BOX_TR << std::endl; + std::cout << CLI_BOX_V << "Load a script from file into MetaCall " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << CLI_BOX_H << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Usage: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "load ... " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " : identifier to the type of script " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " options : " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " mock - Mock (for testing purposes) " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " py - Python " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " node - NodeJS " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " rb - Ruby " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " cs - C# NetCore " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " cob - Cobol " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " ts - TypeScript " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " js - V8 JavaScript Engine " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " file - Files (for handling file systems) " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " ... : relative or absolute path to the script(s) " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Example: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "load node concat.js " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "load py example.py " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "load rb hello.rb " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Result: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Script (concat.js) loaded correctly " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_BL << CLI_BOX_H << CLI_BOX_BR << std::endl << std::endl; /* Inspect command */ - std::cout << "\t┌────────────────────────────────────────────────────────────────────────────────────────┐" << std::endl; - std::cout << "\t│ Show all runtimes, modules and functions (with their signature) loaded into MetaCall │" << std::endl; - std::cout << "\t│────────────────────────────────────────────────────────────────────────────────────────│" << std::endl; - std::cout << "\t│ Usage: │" << std::endl; - std::cout << "\t│ inspect │" << std::endl; - std::cout << "\t│ │" << std::endl; - std::cout << "\t│ Example: │" << std::endl; - std::cout << "\t│ inspect │" << std::endl; - std::cout << "\t│ │" << std::endl; - std::cout << "\t│ Result: │" << std::endl; - std::cout << "\t│ runtime node { │" << std::endl; - std::cout << "\t│ module concat { │" << std::endl; - std::cout << "\t│ function concat(left, right) │" << std::endl; - std::cout << "\t│ } │" << std::endl; - std::cout << "\t│ } │" << std::endl; - std::cout << "\t└────────────────────────────────────────────────────────────────────────────────────────┘" << std::endl + std::cout << CLI_BOX_TL << CLI_BOX_H << CLI_BOX_TR << std::endl; + std::cout << CLI_BOX_V << "Show all runtimes, modules and functions (with their signature) loaded into MetaCall " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << CLI_BOX_H << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Usage: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "inspect " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Example: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "inspect " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "Result: " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "runtime node { " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " module concat { " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " function concat(left, right) " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << " } " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_V << "} " << CLI_BOX_VR << std::endl; + std::cout << CLI_BOX_BL << CLI_BOX_H << CLI_BOX_BR << std::endl << std::endl; /* Eval command */ - std::cout << "\t┌────────────────────────────────────────────────────────────────────────────────────────┐" << std::endl; - std::cout << "\t│ Evaluate a code snippet with the specified runtime tag │" << std::endl; - std::cout << "\t│────────────────────────────────────────────────────────────────────────────────────────│" << std::endl; - std::cout << "\t│ Usage: │" << std::endl; - std::cout << "\t│ eval