Skip to content

Commit 1e9ef37

Browse files
authored
[darwin-framework-tool][interactive] The multiline prompt makes it difficult to modify command with backspace (project-chip#36267)
1 parent c50c591 commit 1e9ef37

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm

+15-5
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@
2727
#include <editline.h>
2828
#include <stdlib.h>
2929

30-
constexpr char kInteractiveModePrompt[] = "Stop and restart stack: [Ctrl+_] & [Ctrl+^]\n"
31-
"Trigger exit(0): [Ctrl+@]\n"
32-
"Quit Interactive: 'quit()'\n"
33-
">>> ";
30+
constexpr char kInteractiveModeInstruction[] = "╔══════════════════════════════════════════════════════════════════╗\n"
31+
"║ Interactive Mode ║\n"
32+
"╠══════════════════════════════════════════════════════════════════╣\n"
33+
"║ Stop and restart stack: [Ctrl+_] & [Ctrl+^ ] ║\n"
34+
"║ Trigger exit(0) : [Ctrl+@] ║\n"
35+
"║ Quit Interactive : 'quit()' or `quit` ║\n"
36+
"╚══════════════════════════════════════════════════════════════════╝\n";
37+
constexpr char kInteractiveModePrompt[] = ">>> ";
3438
constexpr char kInteractiveModeHistoryFilePath[] = "/tmp/darwin_framework_tool_history";
3539
constexpr char kInteractiveModeStopCommand[] = "quit()";
40+
constexpr char kInteractiveModeStopAlternateCommand[] = "quit";
3641
constexpr char kCategoryError[] = "Error";
3742
constexpr char kCategoryProgress[] = "Info";
3843
constexpr char kCategoryDetail[] = "Debug";
@@ -277,6 +282,11 @@ void ENFORCE_FORMAT(3, 0) InteractiveServerLoggingCallback(const char * module,
277282
printf("%s\n", mAdditionalPrompt.Value());
278283
ClearLine();
279284
}
285+
286+
ClearLine();
287+
printf("%s", kInteractiveModeInstruction);
288+
ClearLine();
289+
280290
command = readline(kInteractiveModePrompt);
281291

282292
// Do not save empty lines
@@ -391,7 +401,7 @@ el_status_t ExitFunction()
391401

392402
bool InteractiveCommand::ParseCommand(char * command, int * status)
393403
{
394-
if (strcmp(command, kInteractiveModeStopCommand) == 0) {
404+
if (strcmp(command, kInteractiveModeStopCommand) == 0 || strcmp(command, kInteractiveModeStopAlternateCommand) == 0) {
395405
ExecuteDeferredCleanups();
396406
return NO;
397407
}

0 commit comments

Comments
 (0)