-
Notifications
You must be signed in to change notification settings - Fork 395
Add support for multiple non-interactive commands #372
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
Add support for multiple non-interactive commands #372
Conversation
Also: * Rename ThemeResolver bean to avoid clash w/ Spring Boot registered ThemeResolver * Move shell runner precedence to public static field to allow extension/access
@@ -33,12 +33,12 @@ | |||
public ThemeRegistry themeRegistry(ObjectProvider<Theme> themes) { | |||
ThemeRegistry registry = new ThemeRegistry(); | |||
registry.register(Theme.of("default", ThemeSettings.themeSettings())); | |||
themes.orderedStream().forEachOrdered(theme -> registry.register(theme)); | |||
themes.orderedStream().forEachOrdered(registry::register); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[UNRELATED] Suggestion from IDEA (I agreed w/ it 😸 )
return registry; | ||
} | ||
|
||
@Bean | ||
public ThemeResolver themeResolver(ThemeRegistry themeRegistry, SpringShellProperties properties) { | ||
public ThemeResolver shellThemeResolver(ThemeRegistry themeRegistry, SpringShellProperties properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was clashing w/ the non-shell Spring MVC theme resolver bean in SB.
* The precedence at which this runner is ordered by the DefaultApplicationRunner - which also controls | ||
* the order it is consulted on the ability to handle the current shell. | ||
*/ | ||
public static final int PRECEDENCE = InteractiveShellRunner.PRECEDENCE - 50; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposed the order so that extenders can easily put other runners in front of/behind of a particular runner w/o knowing the core relation runner order relations
|
||
public NonInteractiveShellRunner(Shell shell, ShellContext shellContext) { | ||
this.shell = shell; | ||
this.shellContext = shellContext; | ||
this.lineParser = new DefaultParser(); | ||
this.commandsFromInputArgs = (args) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change we took ApplicationArguments and created a single command out of it where each word in the command is one of the source args.
With this change the default is to take the ApplicationArguments and create a single command STRING out of it. It then in turn gets broken into words via the single ParseLineInput/Provider.
This allows extenders to pass in list of string commands such as:
history --file foo.txt
task create --force --name blah
....
thx, lgtm |
- Fix issue when empty args resulted runner to think it should handle this scenario effectively hijacking interactive mode. - This bug were added by previous rework on #372
Also:
This was needed to support
spring.shell.commandFile
option in SCDF shell. I originally implemented it in SCDF by creating a separate NonInteractiveShellRunner. However, its cleaner to simply support N commands here and let thecommandfile->commands
come in via customizer in SCDF (see here).