Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class NonInteractiveShellRunner implements ShellRunner {
private final CommandRegistry commandRegistry;

// Use a no-op PrintWriter since output is not needed in non-interactive mode
private final PrintWriter outputWriter = new PrintWriter(PrintWriter.nullWriter());
private PrintWriter outputWriter = new PrintWriter(PrintWriter.nullWriter());

// Use a no-op InputReader since input is not needed in non-interactive mode
private final InputReader inputReader = new InputReader() {
Expand All @@ -66,6 +66,12 @@ public NonInteractiveShellRunner(CommandParser commandParser, CommandRegistry co
this.commandExecutor = new CommandExecutor(commandRegistry);
}

public NonInteractiveShellRunner(CommandParser commandParser, CommandRegistry commandRegistry,
PrintWriter outputWriter) {
this(commandParser, commandRegistry);
this.outputWriter = outputWriter;
}

@Override
public void run(String[] args) throws Exception {
if (ObjectUtils.isEmpty(args)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ExitStatus execute(CommandContext commandContext) throws Exception {
private void executeCommand(CommandContext commandContext, String input) throws Exception {
String[] commandTokens = input.split(" ");
NonInteractiveShellRunner shellRunner = new NonInteractiveShellRunner(this.commandParser,
commandContext.commandRegistry());
commandContext.commandRegistry(), commandContext.outputWriter());
shellRunner.run(commandTokens);
}

Expand Down