Skip to content

Commit

Permalink
Fixed EOF (ctrl + D)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDyakonov committed Mar 20, 2023
1 parent 67591c0 commit 666d9b7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 35 deletions.
85 changes: 51 additions & 34 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/main/java/client/ui/ConsoleUI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package client.ui;

import server.exception.CommandException;
import server.services.BuilderType;
import server.services.CommandExecutor;

Expand All @@ -8,6 +9,8 @@
import java.io.InputStreamReader;
import java.util.Objects;

import static client.ui.ConsoleColors.error;

/**
* The type Console ui.
*/
Expand All @@ -34,7 +37,7 @@ public void start() {
String command;

try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
while (!Objects.equals(command = reader.readLine(), "exit")) {
while (!Objects.equals(command = reader.readLine(), "exit") && !Objects.equals(command, null)) {
executor.executeCommand(command, reader, null, BuilderType.CMD);
}
} catch (IOException e) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/server/services/CommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import server.controller.HumanControllerImpl;
import server.exception.ApplicationException;
import server.exception.ArgumentException;
import server.exception.CommandException;
import server.model.dto.HumanBeingRequestDTO;
import server.services.builders.HumanBeingRequestDTOBuilder;

Expand Down Expand Up @@ -80,6 +81,7 @@ private void executeScript(String scriptName, BufferedReader reader) {
public void executeCommand(String command, BufferedReader reader, BufferedReader reader2, BuilderType builderType) {
long id;
try {
System.out.println(command);
String[] compositeCommand = command.split(" ");
history.addCommandToHistory(compositeCommand[0]);
if (compositeCommand.length > 1) {
Expand Down

0 comments on commit 666d9b7

Please sign in to comment.