Skip to content

Commit

Permalink
[darwin-framework-tool][interactive] The multiline prompt makes it di…
Browse files Browse the repository at this point in the history
…fficult to modify command with backspace (#36267)
  • Loading branch information
vivien-apple authored Oct 28, 2024
1 parent c50c591 commit 1e9ef37
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@
#include <editline.h>
#include <stdlib.h>

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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1e9ef37

Please sign in to comment.