Skip to content

Output is not displayed in non-interactive mode when using CommandContext #1288

@scottfrederick

Description

@scottfrederick

When running in non-interactive mode, output sent to CommandContext.outputWriter() is not displayed. This is due to NonInteractiveShellRunner explicitly configuring the outputWriter to discard the output. Why would you not want to see command output in non-interactive mode?

Steps to reproduce

Run the spring-shell-sample-non-interactive sample and pass one of the built-in commands like help or version. The expected output from the built-in command is not displayed.

Or, change the spring-shell-sample-non-interactive sample command from:

	@Command
	public void hi() {
		System.out.println("Hello world!");
	}

to

	@Command
	public void hi(CommandContext commandContext) {
		PrintWriter outputWriter = commandContext.outputWriter();
		outputWriter.println("Hello world!");
		outputWriter.flush();
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/need-triageTeam needs to triage and take a first look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions