Skip to content

Components can't use interactive mode without tty #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jvalkeal opened this issue Jun 11, 2022 · 0 comments · Fixed by #448
Closed

Components can't use interactive mode without tty #444

jvalkeal opened this issue Jun 11, 2022 · 0 comments · Fixed by #448
Milestone

Comments

@jvalkeal
Copy link
Contributor

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).

@jvalkeal jvalkeal added this to the 2.1.0-RC1 milestone Jun 11, 2022
jvalkeal added a commit to jvalkeal/spring-shell that referenced this issue Jun 15, 2022
- Adding a concept of no-tty which in this commit simply
  tracks DumbTerminal as jline creates that if there nothing
  better.
- For components without tty don't go to interaction loop.
- For new sample show that we can at least manually handle
  required option with a flow while command option is not
  required.
- Fixes spring-projects#444
jvalkeal added a commit that referenced this issue Jun 15, 2022
- Adding a concept of no-tty which in this commit simply
  tracks DumbTerminal as jline creates that if there nothing
  better.
- For components without tty don't go to interaction loop.
- For new sample show that we can at least manually handle
  required option with a flow while command option is not
  required.
- Fixes #444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant