Improve cli code formatting

This commit is contained in:
Paolo Di Lorenzo
2025-06-19 17:28:09 -04:00
parent 3d04722d4f
commit b234400614
4 changed files with 12 additions and 10 deletions
+2 -2
View File
@@ -20,13 +20,13 @@ let package = Package(
],
targets: [
.target(name: "ChessKit"),
.testTarget(name: "ChessKitTests", dependencies: ["ChessKit"]),
.executableTarget(
name: "chesskit-cli",
dependencies: [
"ChessKit",
.product(name: "Dye", package: "dye")
]
),
.testTarget(name: "ChessKitTests", dependencies: ["ChessKit"])
)
]
)
+1 -1
View File
@@ -54,7 +54,7 @@ class CLI {
case nil:
write("Unrecognized command ", as: .error)
write("\(input)\n")
case .exit:
case .quit:
write("Goodbye\n", as: .success)
case .board:
write("\(board)\n")
+3 -3
View File
@@ -4,7 +4,7 @@
//
enum Command: Equatable {
case exit
case quit
case board
case clear
case help
@@ -19,8 +19,8 @@ enum Command: Equatable {
let args = input.count > 1 ? Array(input.dropFirst()) : [String]()
switch command {
case "exit", "quit", "q":
return .exit
case "quit", "q", "exit":
return .quit
case "board", "b":
return .board
case "clear", "c":
+6 -4
View File
@@ -6,11 +6,13 @@
var cli = CLI()
cli.startUp()
runLoop: while true {
while true {
print(">> ", terminator: "")
guard let input = readLine(), !input.isEmpty else { continue }
guard let input = readLine(), !input.isEmpty else {
continue
}
if cli.process(input: input) == .exit {
break runLoop
if cli.process(input: input) == .quit {
break
}
}