From 1e9ef37d299054c2b1a58d20e145e109ed6faa85 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 28 Oct 2024 19:32:55 +0100 Subject: [PATCH] [darwin-framework-tool][interactive] The multiline prompt makes it difficult to modify command with backspace (#36267) --- .../interactive/InteractiveCommands.mm | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm index 2652e2c2364101..cfad15b781e129 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm @@ -27,12 +27,17 @@ #include #include -constexpr char kInteractiveModePrompt[] = "Stop and restart stack: [Ctrl+_] & [Ctrl+^]\n" - "Trigger exit(0): [Ctrl+@]\n" - "Quit Interactive: 'quit()'\n" - ">>> "; +constexpr char kInteractiveModeInstruction[] = "╔══════════════════════════════════════════════════════════════════╗\n" + "║ Interactive Mode ║\n" + "╠══════════════════════════════════════════════════════════════════╣\n" + "║ Stop and restart stack: [Ctrl+_] & [Ctrl+^ ] ║\n" + "║ Trigger exit(0) : [Ctrl+@] ║\n" + "║ Quit Interactive : 'quit()' or `quit` ║\n" + "╚══════════════════════════════════════════════════════════════════╝\n"; +constexpr char kInteractiveModePrompt[] = ">>> "; constexpr char kInteractiveModeHistoryFilePath[] = "/tmp/darwin_framework_tool_history"; constexpr char kInteractiveModeStopCommand[] = "quit()"; +constexpr char kInteractiveModeStopAlternateCommand[] = "quit"; constexpr char kCategoryError[] = "Error"; constexpr char kCategoryProgress[] = "Info"; constexpr char kCategoryDetail[] = "Debug"; @@ -277,6 +282,11 @@ void ENFORCE_FORMAT(3, 0) InteractiveServerLoggingCallback(const char * module, printf("%s\n", mAdditionalPrompt.Value()); ClearLine(); } + + ClearLine(); + printf("%s", kInteractiveModeInstruction); + ClearLine(); + command = readline(kInteractiveModePrompt); // Do not save empty lines @@ -391,7 +401,7 @@ el_status_t ExitFunction() bool InteractiveCommand::ParseCommand(char * command, int * status) { - if (strcmp(command, kInteractiveModeStopCommand) == 0) { + if (strcmp(command, kInteractiveModeStopCommand) == 0 || strcmp(command, kInteractiveModeStopAlternateCommand) == 0) { ExecuteDeferredCleanups(); return NO; }