I’m stuck on Stage #NI6
I’ve tried:
I completed what I thought was my implementation for this stage but I feel stuck currently between two tests. When I fix for one, the other fails and vice versa.
Here are my logs:
1st Error I run into:
remote: [tester::#NI6] Writing file "/tmp/foo/f 19" with content "strawberry grape."
remote: [tester::#NI6] Writing file "/tmp/foo/f 62" with content "pineapple strawberry."
remote: [tester::#NI6] Writing file "/tmp/foo/f 87" with content "apple pineapple."
remote: [your-program] $ cat '/tmp/foo/f 19' '/tmp/foo/f 62' '/tmp/foo/f 87'
remote: [your-program] strawberry grape.pineapple strawberry.apple pineapple.
remote: [tester::#NI6] Expected prompt ("$ ") but received ""
remote: [your-program] $
remote: [tester::#NI6] Assertion failed.
remote: [tester::#NI6] Test failed
At first I took this as "I should be putting a ‘$’ infront of the cat commands output but when I go ahead and do that I get the following failed test:
remote: [tester::#NI6] Writing file "/tmp/baz/f 30" with content "strawberry mango."
remote: [tester::#NI6] Writing file "/tmp/baz/f 65" with content "orange apple."
remote: [tester::#NI6] Writing file "/tmp/baz/f 13" with content "orange strawberry."
remote: [your-program] $ cat '/tmp/baz/f 30' '/tmp/baz/f 65' '/tmp/baz/f 13'
remote: [your-program] $ strawberry mango.orange apple.orange strawberry.
remote: [tester::#NI6] Output does not match expected value.
remote: [tester::#NI6] Expected: "strawberry mango.orange apple.orange strawberry."
remote: [tester::#NI6] Received: "$ strawberry mango.orange apple.orange strawberry."
remote: [your-program] $
remote: [your-program] $
remote: [tester::#NI6] Assertion failed.
remote: [tester::#NI6] Test failed
This tells me we should not have the ‘$’ for the output.
At this point I am unsure what to do. I thought maybe the first test failing is refering to the line after the command is run but when I test locally I still see that this works as I would expect,
e.g.
$ cat 1.bat
apple blueberry.
$
I feel like at this point I am really just missing one of the requirements and its flying over my head. Any help or guidence would be super appreciated! TIA
And here’s a snippet of my code:
while (true) {
print("$ ")
val input = readlnOrNull()?.trim() //
if (input.isNullOrBlank()) continue
val commandNameAndArgs = input.split(" ", limit=2)
val commandName = commandNameAndArgs.first()
val argumentsString = commandNameAndArgs.getOrNull(1)
val formattedArguments = formatArguments(argumentsString)
val arguments = if (commandName == "echo") listOf(formattedArguments?.raw ?: "")
else formattedArguments?.normalized ?: emptyList()
when(val result = handler.executeCommand(commandName, arguments)) {
is CommandResult.Success -> {
result.message?.let { message ->
if (commandName != "echo" && commandName != "cat") {
message.lines().forEach { println("$ $it") }
} else {
println(message)
}
}
}
is CommandResult.Failure -> {
result.message?.let { message ->
if (commandName != "echo" && commandName != "cat") {
message.lines().forEach { println("$ $it") }
} else {
println(message)
}
}
}
is CommandResult.Terminate -> {
if (result.code == 0) { kotlin.system.exitProcess(0) } else return
}
}
}