Skip to content

Components can't use interactive mode without tty #444

Closed
@jvalkeal

Description

@jvalkeal

Components like StringInput and others either used manually or via ComponentFlow should not try to enter interactive mode if there is no tty as there would never be any user input.

First issue is that components should not even fail without tty

$ java -jar spring-shell-samples/target/spring-shell-samples-2.1.0-SNAPSHOT.jar component string --mask false < /dev/null
java.lang.NullPointerException 
java.lang.NullPointerException
	at org.springframework.shell.component.StringInput.read(StringInput.java:87)
	at org.springframework.shell.component.StringInput.read(StringInput.java:39)

Secondly if component is not configured to accept default values, it should never ask anything from a user.

We probably need to return either empty context for component result or having everything within context empty/null. This is usually beyond command parsing and start of an command execution so we can't handle everything within core shell itself. Essentially user need to check and throw exception indicating that some options were missing(which is a bit awkward as command option may not be required as component itself may have a default).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions