@@ -15,27 +15,19 @@ import SWBUtil
15
15
16
16
import Foundation
17
17
18
- let kHistoryFilePath = " ~/.swbuild_history "
19
- let kMaxHistoryLines = 100
20
-
21
18
func swbuild_handle_command_result( result: SWBServiceConsoleResult ) {
22
19
print ( result. output, terminator: " " )
23
20
}
24
21
25
22
/// Process a command line.
26
23
///
27
24
/// - returns: True if the console should continue handling commands, otherwise the console should quit.
28
- func swbuild_process_command( console: SWBBuildServiceConsole , command: String , historyPath : String ) async -> ( shouldContinue: Bool , success: Bool ) {
25
+ func swbuild_process_command( console: SWBBuildServiceConsole , command: String ) async -> ( shouldContinue: Bool , success: Bool ) {
29
26
// Ignore empty commands.
30
27
if command. isEmpty {
31
28
return ( true , true )
32
29
}
33
30
34
- // Add the line to the history.
35
- swb_add_history ( command)
36
- swb_write_history ( historyPath)
37
- swb_history_truncate_file ( historyPath, kMaxHistoryLines)
38
-
39
31
// Process the line.
40
32
let ( result, success) = await console. sendCommandString ( command)
41
33
swbuild_handle_command_result ( result: result)
@@ -71,24 +63,20 @@ func swbuild_repl() async throws -> Bool {
71
63
// Save the terminal attributes (and restore them and exit).
72
64
return try await withTerminalAttributes { terminalAttributes in
73
65
return try await withServiceConsole { console in
74
- let historyPath = ( kHistoryFilePath as NSString ) . expandingTildeInPath
75
-
76
- // Read in the command history.
77
- swb_read_history ( historyPath)
78
-
79
66
// Disable echo, after all readline initialization is done.
80
67
terminalAttributes. disableEcho ( )
81
68
82
69
var ok = true
83
70
var shouldContinue = true
84
71
while shouldContinue {
85
- guard let line = swb_readline ( " swbuild> " ) else {
72
+ print ( " swbuild> " , terminator: " " )
73
+ guard let line = readLine ( ) else {
86
74
// If we received the EOF then exit.
87
75
print ( )
88
76
break
89
77
}
90
78
91
- ( shouldContinue, ok) = await swbuild_process_command ( console: console, command: line, historyPath : historyPath )
79
+ ( shouldContinue, ok) = await swbuild_process_command ( console: console, command: line)
92
80
}
93
81
94
82
return ok
0 commit comments