From c4ebc5a6f454cc2233e0b96f7c1ed9f161e3f8fc Mon Sep 17 00:00:00 2001 From: devs6186 Date: Thu, 12 Mar 2026 03:41:25 +0530 Subject: [PATCH 1/2] fix(cli): use ASCII box-drawing characters on Windows to fix misaligned help output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The help command in metacallcli renders a bordered table using Unicode box-drawing characters (┌ ─ ┐ │ └ ┘). On Windows the default console code page (CP850/CP1252) cannot render those code points, causing every border character to either display as a question mark or take up a different column width, making the entire help output unreadable. Introduce CLI_BOX_* macros that select ASCII equivalents (+, -, |) on Windows (any of _WIN32, _WIN64, WIN32, WIN64) and keep the original Unicode characters on all other platforms. Replace all hardcoded border strings in the help() function with these macros. No behaviour change on Linux or macOS. Fixes #537 --- .../source/cli_core_plugin.cpp | 315 ++++++++++-------- 1 file changed, 167 insertions(+), 148 deletions(-) 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..6434fca308 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 @@ -32,6 +32,25 @@ #include #include +#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) +/* Use ASCII borders on Windows so help output aligns correctly in console */ +#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 "|" +#else +#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 "│" +#endif + /* Error messages */ #define LOAD_ERROR "Failed to load a script" #define INSPECT_ERROR "Failed to inspect MetaCall context" @@ -462,178 +481,178 @@ 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